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


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

Re: Marshalling deques

From "Bo Persson" <bop@gmb.dk>
Newsgroups comp.lang.c++
Subject Re: Marshalling deques
Date 2011-08-18 14:24 +0200
Message-ID <9b4ekaFvvhU1@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> <j2gtul$21l$1@dont-email.me> <51f7e8e2-f7ce-42e1-b404-a005f166dfa0@l37g2000yqd.googlegroups.com>

Show all headers | View raw


Ebenezer wrote:
> On Aug 17, 12:32 pm, Victor Bazarov <v.baza...@comcast.invalid>
> wrote:
>> On 8/17/2011 12:28 PM, 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.
>>
>> So?
>
> It seems that being able to bypass the relatively slower deque
> iterators would be helpful.
>
> What I need to know from a deque is what is the first element
> of each of it's chunks.  Say for example, a deque has 3 chunks
> and 500 elements.  The interface would give me indices something
> like: 0, 200, 400.  The indices could be served up in a vector
> so I don't have to deal with deque iteration.

There are additional bookkeping involved because the first and last 
chunk may be only partially filled.


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