Sequential and Associative containers

U

utab

Hi there,

Can you please explain me why there are sequential and associative
containers in c++ on some examples and briefly specify the advantages
of using one over the other(and also from the point of performance as
well, I know that it is hard to answer because this is dependent on the
application that you would like to develop :)) )

Thanks for all comments in advance.
 
B

Ben Pope

utab said:
Hi there,

Can you please explain me why there are sequential and associative
containers in c++ on some examples and briefly specify the advantages
of using one over the other(and also from the point of performance as
well, I know that it is hard to answer because this is dependent on the
application that you would like to develop :)) )

What book are you reading that does not explain the differences between
containers and their associated performance characteristics?

I have "Effective STL" by Scott Meyers, and that has good descriptions.

Ben Pope
 
D

Daniel T.

"utab said:
Hi there,

Can you please explain me why there are sequential and associative
containers in c++ on some examples and briefly specify the advantages
of using one over the other(and also from the point of performance as
well, I know that it is hard to answer because this is dependent on the
application that you would like to develop :)) )

Thanks for all comments in advance.

<http://www.sgi.com/tech/stl/AssociativeContainer.html>
[An Associative Container] differs from a Sequence in that it does not
provide a mechanism for inserting an element at a specific position.

Complexity guarantees
* Average complexity for erase key is at most O(log(size()) + count(k)).
* Average complexity for erase element is constant time.
* Average complexity for erase range is at most O(log(size()) + N),
where N is the number of elements in the range.
* Average complexity for count is at most O(log(size()) + count(k)).
* Average complexity for find is at most logarithmic.
* Average complexity for equal range is at most logarithmic.

Models
* set
* multiset
* map
* multimap

<http://www.sgi.com/tech/stl/Sequence.html>
Complexity guarantees
* The fill constructor, default fill constructor, and range constructor
are linear.
* Front is amortized constant time.
* Fill insert, range insert, and range erase are linear.
* The complexities of single-element insert and erase are sequence
dependent.

Models
* vector
* deque
* list
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top