Basic Container Properties

◀ The Standard Template Library▶ Basic Sequence Container Properties
Amazon The following table describes basic properties of containers such as constructors and functions, common to all container types. In the table, C represents a container type, including its identifier, such as vector<string> and list<int>; a and b represent objects of C.
ExpressionExplanation
C::iterator aa is an iterator of C
C a;creates a container object named a
C a(b);a uses copy constructor to initialize its contents to bs contents
C a = b;as contents are initialized to bs contents
a.size()returns the number of elements
a.begin()returns an iterator pointing to the first element
a.end()returns an iterator pointing to the place immediately past the last element
a == breturns true if a and b have the same size and each element in a is the same as the corresponding element in b; returns false otherwise
a != breturns false if a and b have the same size and each element in a is the same as the corresponding element in b; returns true otherwise
a.swap(b)swaps the contents of a and those of b
These properties again are common to every container type. Whether you are using a vector, list, or stack you can use any of these properties to manipulate the objects.


Next we’ll identify the sequence container types and describe their properties!
◀ The Standard Template Library▶ Basic Sequence Container Properties

fShare
Questions? Let me know!