Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Should I be using something other than raw pointers as a helper indexinto a collection?

Reply
Thread Tools

Should I be using something other than raw pointers as a helper indexinto a collection?

 
 
Öö Tiib
Guest
Posts: n/a
 
      06-02-2013
On Sunday, 2 June 2013 23:54:34 UTC+3, (E-Mail Removed) wrote:
> On Saturday, June 1, 2013 7:01:03 PM UTC, Öö Tiib wrote:
> >
> > I haven't measured, but lets say whole boost with everything built and
> > ready takes 10Gb. 10Gb of hard-drive space costs less than 1 euro. The
> > built executable that uses something from boost is about as large as
> > built executable that does same thing without using anything from boost..
> >

> There are differences in the size of executables --
> http://webEbenezer.net/comparison.html
> One time the Boost version is 2.6 times larger and
> another time it's 4 times larger than Ebenezer versions.


Probably that boost serialize does more than than your software.
Can the Ebenezer serialize that Boost.MultiIndex that I suggested
to OP? As XML? Actually I dislike Boost.Serialize since it feels
complicated.

> I think it makes sense to "chew the meat and spit the
> bones" with Boost. Some of the libraries are excellent,
> but not all of them. The intrusive containers
> library and some of the other containers in Boost
> are examples of what I think are great libraries.


When I feel that I do not understand how it does what it
does then I avoid using it. I generally avoid using source
code that appears too complex for me to maintain.
Performance is of secondary importance. If I can
maintain it then I can profile it too if needed.
 
Reply With Quote
 
 
 
 
woodbrian77@gmail.com
Guest
Posts: n/a
 
      06-03-2013
On Sunday, June 2, 2013 9:34:36 PM UTC, Öö Tiib wrote:
> On Sunday, 2 June 2013 23:54:34 UTC+3, (E-Mail Removed) wrote:
>
> > There are differences in the size of executables --
> > http://webEbenezer.net/comparison.html
> > One time the Boost version is 2.6 times larger and
> > another time it's 4 times larger than Ebenezer versions.

>
> Probably that boost serialize does more than than your software.
> Can the Ebenezer serialize that Boost.MultiIndex that I suggested
> to OP? As XML?


"Yes" to the first question and "no" to the second.


> Actually I dislike Boost.Serialize since it feels
> complicated.


Sometimes I think that an advantage to on line code
generation, an unusual approach in 2002, is that
people have been slow to jump on the bandwagon. I
would have liked to have more users, but on the other
hand it makes it easier to make interface breaking
changes while there aren't many that are affected.
A lot has been learned about interface design over
the past ten years so I hope we're able to incorpor-
ate more of that sooner than later.

>
> > I think it makes sense to "chew the meat and spit the
> > bones" with Boost. Some of the libraries are excellent,
> > but not all of them. The intrusive containers
> > library and some of the other containers in Boost
> > are examples of what I think are great libraries.

>
> When I feel that I do not understand how it does what it
> does then I avoid using it. I generally avoid using source
> code that appears too complex for me to maintain.
> Performance is of secondary importance. If I can
> maintain it then I can profile it too if needed.


The compression library I use is only 991 lines, but I
don't understand much of it. Probably it would take me
weeks to get some idea of how it works. I'd communicate
with the author though if there is a problem with the
library. He's answered some questions I've had so
hopefully he'll be available if there's a problem with it.


Brian
Ebenezer Enterprises - So far G-d has helped us.
http://webEbenezer.net
 
Reply With Quote
 
 
 
 
Öö Tiib
Guest
Posts: n/a
 
      06-03-2013
On Monday, 3 June 2013 05:23:14 UTC+3, (E-Mail Removed) wrote:
> On Sunday, June 2, 2013 9:34:36 PM UTC, Öö Tiib wrote:
> > When I feel that I do not understand how it does what it
> > does then I avoid using it. I generally avoid using source
> > code that appears too complex for me to maintain.
> > Performance is of secondary importance. If I can
> > maintain it then I can profile it too if needed.

>
> The compression library I use is only 991 lines, but I
> don't understand much of it. Probably it would take me
> weeks to get some idea of how it works. I'd communicate
> with the author though if there is a problem with the
> library. He's answered some questions I've had so
> hopefully he'll be available if there's a problem with it.


Sure, perhaps my view of things is because I just like to
understand complex algorithms. Be it compression or linear algebra I
am not happy when using it without feel that I will understand it
if needed. It is written by a human like me and so it certainly
contains defects. Take for example binary search. It is so simple?

Jon Bentley: "While the first binary search was published in 1946,
the first binary search that works correctly for all
values of n did not appear until 1962."
http://googleresearch.blogspot.com/2...it-nearly.html

I do not like needless complexity that is caused by usage of
unsuitable tools. C++ template meta-programming was not designed
into language and so it usually looks like the hack it is. Your
idea to generate code is lot better at the moment.
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      06-03-2013
On Sunday, June 2, 2013 6:12:15 PM UTC+1, K. Frank wrote:
> Hello James (and Balog)!


> The reason I posted the question in the first place is that I
> haven't used smart pointers much in the past, and I have yet
> to use a c++11 smart pointer. Nonetheless, one sees a lot of
> commentary advocating the use of smart pointers (where appropriate,
> of course), and since I don't have a deep understanding of the
> use cases for c++11 (and other) smart pointers, I wanted to make
> sure I wasn't missing anything.


Smart pointers are the current silver bullet. It's a lot easier
for commentators to recommend using a smart pointer everywhere
than for them to recommend actually doing some design. There
are places where smart pointers are an appropriate solution; my
first smart pointers go back some twenty years or more. But
there is no silver bullet, and I've found very few, if any cases
where smart pointers were appropriate in a container.

--
James
 
Reply With Quote
 
woodbrian77@gmail.com
Guest
Posts: n/a
 
      06-03-2013
On Monday, June 3, 2013 2:23:14 AM UTC, (E-Mail Removed) wrote:
> On Sunday, June 2, 2013 9:34:36 PM UTC, Öö Tiib wrote:
>
> > Probably that boost serialize does more than than your software.
> > Can the Ebenezer serialize that Boost.MultiIndex that I suggested
> > to OP? As XML?

>
> "Yes" to the first question and "no" to the second.
>


There are some limitations on our support of multi_index_container:
1. At most one sequenced index.
2. If a sequenced index is used, it must be the
first index listed in the "IndexSpecifierList."
3. Transmission of a multi_index_container will probably not
preserve the relative order of elements that are
considered equal under an ordered_non_unique index.


These limitations permit a process which uses a
multi_index_container to serialize it's data and
then be used in another process that is using a
"single index container" like vector or deque.

I guess the first and third limitations are what are
needed for that. The second one is due to an
implementation difficulty.


Brian
Ebenezer Enterprises
http://webEbenezer.net

 
Reply With Quote
 
Luca Risolia
Guest
Posts: n/a
 
      06-03-2013
K. Frank wrote:

> Hello Group!
>
> I have a collection.
>
> (It happens to be an unordered_map, hence my earlier question
> about possible pointer invalidation, but for the purposes of
> this question it could be a map or set, etc.)
>
> In addition to element access through the built-in features
> of the collection class, I also want quick access to the first
> few elements according to some independent sorting criterion.
>
> Therefore my wrapper class contains not only the underlying
> collection, but a helper index that is a (sorted) set of
> pointers to values in the collection. I am using raw pointers
> for this, basically because I don't see any need to use some
> sort of smart pointer.


Reference wrappers might be a convenient alternative to raw pointers.

For example:

using namespace std;

unordered_map<int, int> m{{3, 1}, {2, 2}, {1, 3}};
vector<reference_wrapper<decltype(m)::value_type>> v{begin(m), end(m)};
sort(begin(v), end(v), less<decltype(m)::value_type>{});

 
Reply With Quote
 
Balog Pal
Guest
Posts: n/a
 
      06-04-2013
On 6/3/2013 11:26 PM, Luca Risolia wrote:
> Reference wrappers might be a convenient alternative to raw pointers.
>
> For example:
>
> using namespace std;
>
> unordered_map<int, int> m{{3, 1}, {2, 2}, {1, 3}};
> vector<reference_wrapper<decltype(m)::value_type>> v{begin(m), end(m)};


Hm, is it worth?

> sort(begin(v), end(v), less<decltype(m)::value_type>{});


I have a small suite of function adapters for that case from the old
times. Nowadays we have lambda for solo cases too.
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      06-04-2013
On Sat, 2013-06-01, Paavo Helde wrote:
> "K. Frank" <(E-Mail Removed)> wrote in news:f302bee4-aa53-48e3-a3f7-
> http://www.velocityreviews.com/forums/(E-Mail Removed):
>>
>> However (unlike many participants in this group) I tend to stay away
>> from boost as it is large and unwieldy. I generally avoid large and
>> unwieldy packages unless they offer nearly irreplaceable
>> functionality.

....
> It is true that it is large but this only affects the initial download
> time.


It depends on your environment. (Parts of) Boost is a standard part
of Debian Linux, and there it's split into >20 packages.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen ASP .Net 1 05-18-2007 09:24 AM
What's the purpose of the helper cache and is there a way to just turn off helper cache-ing? kevin Ruby 1 07-21-2006 03:42 AM
how to fill a dataset using something OTHER than a SQL query? darrel ASP .Net 5 05-06-2005 02:12 AM
Using something other than ';' to separate statements Jaime Wyant Python 9 03-31-2005 12:27 AM
using a DataGrid with something other than a DataTable Andy Fish ASP .Net 2 08-11-2004 02:22 PM



Advertisments