Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #9037

Re: Marshalling deques

From "Bo Persson" <bop@gmb.dk>
Newsgroups comp.lang.c++
Subject Re: Marshalling deques
Date 2011-08-18 14:22 +0200
Message-ID <9b4efhFv23U1@mid.individual.net> (permalink)
References <a824c198-7623-4124-981b-0aaa1c28d90c@a4g2000yqg.googlegroups.com> <9b1j3vFbf3U1@mid.individual.net> <27aeb4b8-3d21-435c-bfe8-be22eb62fe75@i9g2000yqk.googlegroups.com>

Show all headers | View raw


Ebenezer wrote:
> On Aug 17, 5:23 am, "Bo Persson" <b...@gmb.dk> wrote:
>> Ebenezer wrote:
>>> When you have a vector of a primitive type, rather than
>>> iterating through each element, you can marshal the vector
>>> with the address of the first element and multiply the size
>>> of the vector with the size of each element like this:
>>
>>> buf.Receive(&*vec.begin(), vec.size() * sizeof(T));
>>
>>> I'd like to do something similar with deques, but they are
>>> implemented in chunks rather than a single chunk. How
>>> to get the address and size of each chunk, though? Tia.
>>
>>> http://www.gotw.ca/gotw/054.htm
>>
>> You cannot.
>>
>> Deque has to use a two level addressing, probably involving an
>> array of pointers to the chunks, but the details are not specified
>> by the standard. There is no interface to this internal structure.
>>
>
> In that case, how about changing the standard?  I believe iterating
> through a deque is more involved than iterating through a vector.

Iterating through a deque is encoded in the iterators. It does take 
about twice as long as iterating a vector.

The advantage is that you can insert and delete at both ends without 
moving the member objects and that the memory is allocated in chunks 
instead of in one large block. That's a trade off!


Bo Persson

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Marshalling deques Ebenezer <woodbrian77@gmail.com> - 2011-08-16 19:13 -0700
  Re: Marshalling deques "Bo Persson" <bop@gmb.dk> - 2011-08-17 12:23 +0200
    Re: Marshalling deques Ebenezer <woodbrian77@gmail.com> - 2011-08-17 09:28 -0700
      Re: Marshalling deques Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-17 13:32 -0400
        Re: Marshalling deques Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 18:41 +0100
          Re: Marshalling deques Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 18:46 +0100
          Re: Marshalling deques Ebenezer <woodbrian77@gmail.com> - 2011-08-17 11:08 -0700
            Re: Marshalling deques Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 19:12 +0100
              Re: Marshalling deques Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 19:21 +0100
        Re: Marshalling deques Ebenezer <woodbrian77@gmail.com> - 2011-08-17 15:06 -0700
          Re: Marshalling deques Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 23:29 +0100
            Re: Marshalling deques Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 23:34 +0100
              Re: Marshalling deques Ebenezer <woodbrian77@gmail.com> - 2011-08-18 08:59 -0700
          Re: Marshalling deques Jeff Flinn <TriumphSprint2000@hotmail.com> - 2011-08-17 21:10 -0400
          Re: Marshalling deques "Bo Persson" <bop@gmb.dk> - 2011-08-18 14:24 +0200
            Re: Marshalling deques Ebenezer <woodbrian77@gmail.com> - 2011-08-18 08:53 -0700
              Re: Marshalling deques Ebenezer <woodbrian77@gmail.com> - 2011-08-19 15:39 -0700
                Re: Marshalling deques Ebenezer <woodbrian77@gmail.com> - 2011-08-22 12:39 -0700
      Re: Marshalling deques "Bo Persson" <bop@gmb.dk> - 2011-08-18 14:22 +0200
  Re: Marshalling deques ptyxs <kerloch@gmail.com> - 2011-08-17 09:43 -0700

csiph-web