Boost logo

Boost Users :

From: Frank Birbacher (bloodymir.crap_at_[hidden])
Date: 2007-08-22 17:56:21


Hi!

Dominick Layfield schrieb:
> I'll take a look at the boost::iostreams stuff to see if I can figure out how to
> make that work. Thanks for the tip, Frank.

See here for an array "Device":
http://www.boost.org/libs/iostreams/doc/classes/array.html#array_source

And here for the stream wrapper:
http://www.boost.org/libs/iostreams/doc/index.html

These two make an istream for reading your char buffer. See the tutorial
at http://www.boost.org/libs/iostreams/doc/index.html for usage
instructions.

> BTW, I don't think a push_back() is any faster for a deque than a vector -- it
> is push_front() that is faster for a deque. From the STL docs at SGI: "The main
> way in which deque differs from vector is that deque also supports constant time
> insertion and removal of elements at the beginning of the sequence".

Yes, the approximate complexity is the same, namely O(1) or "constant
time". But the vector need to enlarge itself from time to time
(althought this takes approximately constant time). A deque does not
need to copy its contents to enlarge itself. You'd need to do some
profiling to find out who's the winner.

Frank


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net