Różnice między wybraną wersją a wersją aktualną.
Next revision | Previous revision | ||
opis_kontenera:bit_vector [2008/12/11 21:57] pkaczoro utworzono |
opis_kontenera:bit_vector [2008/12/11 22:23] (aktualna) pkaczoro |
||
---|---|---|---|
Linia 1: | Linia 1: | ||
====== Bit_vector ====== | ====== Bit_vector ====== | ||
- | Opis | + | ===== Opis ===== |
Bit_vector jest to w zasadzie vector<bool>, ma ten sam interface co vector. Główną różnicą jest to, że bi_vector jest zoptymalizowany pod względem pamięciowym. Vector zawsze wymaga co najmniej 1 bitu na element, a bit_vector dokładnie jednego bitu na element. | Bit_vector jest to w zasadzie vector<bool>, ma ten sam interface co vector. Główną różnicą jest to, że bi_vector jest zoptymalizowany pod względem pamięciowym. Vector zawsze wymaga co najmniej 1 bitu na element, a bit_vector dokładnie jednego bitu na element. | ||
Linia 9: | Linia 10: | ||
Nazwa bit_vector będzie usunięta z przyszłych wersji STL. | Nazwa bit_vector będzie usunięta z przyszłych wersji STL. | ||
- | Example | + | Przykład: |
- | + | <code cpp> | |
- | ''bit_vector V(5); | + | bit_vector V(5); |
V[0] = true; | V[0] = true; | ||
V[1] = false; | V[1] = false; | ||
Linia 20: | Linia 21: | ||
for (bit_vector::iterator i = V.begin(); i < V.end(); ++i) | for (bit_vector::iterator i = V.begin(); i < V.end(); ++i) | ||
cout << (*i ? '1' : '0'); | cout << (*i ? '1' : '0'); | ||
- | cout << endl;'' | + | cout << endl; |
+ | </code> | ||
+ | |||
+ | |||
+ | ^Member ^Where defined ^Description^ | ||
+ | |value_type |Container |The type of object stored in the bit_vector: bool| | ||
+ | |reference |bit_vector |A proxy class that acts as a reference to a single bit. See below for details.| | ||
+ | |const_reference |Container |Const reference to value_type. In bit_vector this is simply defined to be bool.| | ||
+ | |size_type |Container |An unsigned integral type.| | ||
+ | |difference_type |Container |A signed integral type.| | ||
+ | |iterator |Container |Iterator used to iterate through a bit_vector.| | ||
+ | |const_iterator |Container |Const iterator used to iterate through a bit_vector.| | ||
+ | |reverse_iterator |Reversible Container |Iterator used to iterate backwards through a bit_vector.| | ||
+ | |const_reverse_iterator |Reversible Container |Const iterator used to iterate backwards through a bit_vector.| | ||
+ | |iterator begin() |Container |Returns an iterator pointing to the beginning of the bit_vector.| | ||
+ | |iterator end() |Container |Returns an iterator pointing to the end of the bit_vector.| | ||
+ | |const_iterator begin() const |Container |Returns a const_iterator pointing to the beginning of the bit_vector.| | ||
+ | |const_iterator end() const |Container |Returns a const_iterator pointing to the end of the bit_vector.| | ||
+ | |reverse_iterator rbegin() |Reversible Container |Returns a reverse_iterator pointing to the beginning of the reversed bit_vector.| | ||
+ | |reverse_iterator rend() |Reversible Container |Returns a reverse_iterator pointing to the end of the reversed bit_vector.| | ||
+ | |const_reverse_iterator rbegin() const |Reversible Container |Returns a const_reverse_iterator pointing to the beginning of the reversed bit_vector.| | ||
+ | |const_reverse_iterator rend() const |Reversible Container |Returns a const_reverse_iterator pointing to the end of the reversed bit_vector.| | ||
+ | |size_type size() const |Container |Returns the number of elements in the bit_vector.| | ||
+ | |size_type max_size() const |Container |Returns the largest possible size of the bit_vector.| | ||
+ | |size_type capacity() const |bit_vector |See below.| | ||
+ | |bool empty() const |Container |true if the bit_vector's size is 0.| | ||
+ | |reference operator[](size_type n) |Random Access Container |Returns the n'th element.| | ||
+ | |const_reference operator[](size_type n) const |Random Access Container |Returns the n'th element.| | ||
+ | |bit_vector() |Container |Creates an empty bit_vector.| | ||
+ | |bit_vector(size_type n) |Sequence |Creates a bit_vector with n elements.| | ||
+ | |bit_vector(size_type n, bool t) |Sequence |Creates a bit_vector with n copies of t.| | ||
+ | |bit_vector(const bit_vector&) |Container |The copy constructor.| | ||
+ | |~bit_vector() |Container |The destructor.| | ||
+ | |bit_vector& operator=(const bit_vector&) |Container |The assignment operator| | ||
+ | |void reserve(size_t) |bit_vector |See below.| | ||
+ | |reference front() |Sequence |Returns the first element.| | ||
+ | |const_reference front() const |Sequence |Returns the first element.| | ||
+ | |reference back() |Back Insertion Sequence |Returns the last element.| | ||
+ | |const_reference back() const |Back Insertion Sequence |Returns the last element.| | ||
+ | |void push_back(const T&) |Back Insertion Sequence |Inserts a new element at the end.| | ||
+ | |void pop_back() |Back Insertion Sequence |Removes the last element.| | ||
+ | |void swap(bit_vector&) |Container |Swaps the contents of two bit_vectors.| | ||
+ | |void erase(iterator pos) |Sequence |Erases the element at position pos.| | ||
+ | |void erase(iterator first, iterator last) |Sequence |Erases the range [first, last)| | ||
+ | |void clear() |Sequence |Erases all of the elements.| | ||
+ | |||