![]() |
Home | Libraries | People | FAQ | More |
boost::container::segtor
// In header: <boost/container/segtor.hpp> template<typename T, typename Allocator = void, typename Options = void> class segtor : public deque_impl< T, void, true, void > { public: // types typedef T value_type; typedef base_type::allocator_type allocator_type; typedef base_type::pointer pointer; typedef base_type::const_pointer const_pointer; typedef base_type::reference reference; typedef base_type::const_reference const_reference; typedef base_type::size_type size_type; typedef base_type::difference_type difference_type; typedef base_type::iterator iterator; typedef base_type::const_iterator const_iterator; typedef base_type::reverse_iterator reverse_iterator; typedef base_type::const_reverse_iterator const_reverse_iterator; typedef base_type::stored_allocator_type stored_allocator_type; // public member functions segtor(); explicit segtor(const allocator_type &) noexcept; explicit segtor(size_type); segtor(size_type, default_init_t); explicit segtor(size_type, const allocator_type &); segtor(size_type, default_init_t, const allocator_type &); segtor(size_type, const value_type &); segtor(size_type, const value_type &, const allocator_type &); template<typename InIt> segtor(InIt, InIt); template<typename InIt> segtor(InIt, InIt, const allocator_type &); segtor(std::initializer_list< value_type >, const allocator_type & = allocator_type()); segtor(const segtor &); segtor(segtor &&) noexcept; segtor(const segtor &, const allocator_type &); segtor(segtor &&, const allocator_type &); ~segtor() noexcept; segtor & operator=(const segtor &); segtor & operator=(segtor &&); segtor & operator=(std::initializer_list< value_type >); void reserve(size_type); size_type capacity() const noexcept; iterator begin() noexcept; const_iterator begin() const noexcept; iterator end() noexcept; const_iterator end() const noexcept; reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; const_iterator cbegin() const noexcept; const_iterator cend() const noexcept; const_reverse_iterator crbegin() const noexcept; const_reverse_iterator crend() const noexcept; bool empty() const noexcept; size_type size() const noexcept; size_type max_size() const noexcept; reference front(); const_reference front() const; reference back(); const_reference back() const; reference operator[](size_type); const_reference operator[](size_type) const; reference at(size_type); const_reference at(size_type) const; allocator_type get_allocator() const noexcept; const stored_allocator_type & get_stored_allocator() const noexcept; stored_allocator_type & get_stored_allocator() noexcept; void assign(size_type, const value_type &); template<typename InIt> void assign(InIt, InIt); void assign(std::initializer_list< value_type >); void clear() noexcept; template<class... Args> iterator emplace(const_iterator, Args &&...); template<class... Args> reference emplace_back(Args &&...); iterator insert(const_iterator, const value_type &); iterator insert(const_iterator, value_type &&); iterator insert(const_iterator, size_type, const value_type &); template<typename InIt> iterator iterator insert(const_iterator, InIt, InIt); iterator insert(const_iterator, std::initializer_list< value_type >); iterator erase(const_iterator) noexcept; iterator erase(const_iterator, const_iterator) noexcept; void push_back(const value_type &); void push_back(value_type &&); void pop_back() noexcept; void resize(size_type); void resize(size_type, default_init_t); void resize(size_type, const value_type &); void swap(segtor &); // public static functions static size_type get_segment_size() noexcept; static size_type get_block_size() noexcept; // friend functions bool operator==(const segtor &, const segtor &); bool operator!=(const segtor &, const segtor &); bool operator<(const segtor &, const segtor &); bool operator>(const segtor &, const segtor &); bool operator<=(const segtor &, const segtor &); bool operator>=(const segtor &, const segtor &); void swap(segtor &, segtor &); // public data members static const std::size_t is_reservable; };
A segtor (contraction of "segmented vector" is a sequence container that supports random access to elements, constant time insertion and removal of elements at the end, and linear time insertion and removal of elements in the middle.
It's the single-ended version of boost::container::deque: it provides push_back, pop_back, emplace_back, etc., but does not provide push_front, pop_front, or emplace_front.
typename T
The type of object that is stored in the segtor
typename Allocator = void
The allocator used for all internal memory management, use void for the default allocator
typename Options = void
A type produced from boost::container::segtor_options.
segtor public member functionssegtor();
Effects: Default constructs a segtor.
Throws: If allocator_type's default constructor throws.
Complexity: Constant.
explicit segtor(const allocator_type & a) noexcept;
Effects: Constructs a segtor taking the allocator as parameter.
Throws: Nothing
Complexity: Constant.
explicit segtor(size_type n);
Effects: Constructs a segtor and inserts n value initialized values.
Throws: If allocator_type's default constructor throws or T's value initialization throws.
Complexity: Linear to n.
segtor(size_type n, default_init_t);
Effects: Constructs a segtor and inserts n default initialized values.
Throws: If allocator_type's default constructor throws or T's default initialization or copy constructor throws.
Complexity: Linear to n.
Note: Non-standard extension
explicit segtor(size_type n, const allocator_type & a);
Effects: Constructs a segtor that will use a copy of allocator a and inserts n value initialized values.
Throws: If allocator_type's default constructor throws or T's value initialization throws.
Complexity: Linear to n.
segtor(size_type n, default_init_t, const allocator_type & a);
Effects: Constructs a segtor that will use a copy of allocator a and inserts n default initialized values.
Throws: If allocator_type's default constructor throws or T's default initialization or copy constructor throws.
Complexity: Linear to n.
Note: Non-standard extension
segtor(size_type n, const value_type & value);
Effects: Constructs a segtor that will use a copy of allocator a and inserts n copies of value.
Throws: If allocator_type's default constructor throws or T's copy constructor throws.
Complexity: Linear to n.
segtor(size_type n, const value_type & value, const allocator_type & a);
Effects: Constructs a segtor that will use a copy of allocator a and inserts n copies of value.
Throws: If allocator_type's default constructor throws or T's copy constructor throws.
Complexity: Linear to n.
template<typename InIt> segtor(InIt first, InIt last);
Effects: Constructs a segtor that will use a copy of allocator a and inserts a copy of the range [first, last).
Throws: If allocator_type's default constructor throws or T's constructor taking a dereferenced InIt throws.
Complexity: Linear to the range [first, last).
template<typename InIt> segtor(InIt first, InIt last, const allocator_type & a);
Effects: Constructs a segtor that will use a copy of allocator a and inserts a copy of the range [first, last).
Throws: If allocator_type's default constructor throws or T's constructor taking a dereferenced InIt throws.
Complexity: Linear to the range [first, last).
segtor(std::initializer_list< value_type > il, const allocator_type & a = allocator_type());
Effects: Constructs a segtor that will use a copy of allocator a and inserts a copy of the range [il.begin(), il.end()).
Throws: If allocator_type's default constructor throws or T's constructor taking a dereferenced std::initializer_list iterator throws.
Complexity: Linear to the range [il.begin(), il.end()).
segtor(const segtor & x);
Effects: Copy constructs a segtor.
Postcondition: x == *this.
Complexity: Linear to the elements x contains.
segtor(segtor && x) noexcept;
Effects: Move constructor. Moves x's resources to *this.
Throws: If allocator_type's copy constructor throws.
Complexity: Constant.
segtor(const segtor & x, const allocator_type & a);
Effects: Copy constructs a segtor using the specified allocator.
Postcondition: x == *this.
Throws: If allocation throws or T's copy constructor throws.
Complexity: Linear to the elements x contains.
segtor(segtor && x, const allocator_type & a);
Effects: Move constructor using the specified allocator. Moves x's resources to *this if a == allocator_type(). Otherwise copies values from x to *this.
Throws: If allocation or T's copy constructor throws.
Complexity: Constant if a == x.get_allocator(), linear otherwise.
~segtor() noexcept;
Effects: Destroys the segtor. All stored values are destroyed and used memory is deallocated.
Throws: Nothing.
Complexity: Linear to the number of elements.
segtor & operator=(const segtor & x);
Effects: Makes *this contain the same elements as x.
Postcondition: this->size() == x.size(). *this contains a copy of each of x's elements.
Throws: If memory allocation throws or T's copy constructor throws.
Complexity: Linear to the number of elements in x.
segtor & operator=(segtor && x);
Effects: Move assignment. All x's values are transferred to *this.
Throws: If allocator_traits_type::propagate_on_container_move_assignment is false and (allocation throws or value_type's move constructor throws)
Complexity: Constant if allocator_traits_type:: propagate_on_container_move_assignment is true or this->get_allocator() == x.get_allocator(). Linear otherwise.
segtor & operator=(std::initializer_list< value_type > il);
Effects: Makes *this contain the same elements as il.
Postcondition: this->size() == il.size(). *this contains a copy of each of il's elements.
Throws: If memory allocation throws or T's copy constructor throws.
Complexity: Linear to the number of elements in il.
void reserve(size_type n);
Requires: The container must be "reservable" (is_reservable == true)
Effects: If n is less than or equal to capacity() or the container is not reservable, this call has no effect. Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
Throws: If memory allocation throws.
Complexity: Linear to n.
Note: Non-standard extension.
size_type capacity() const noexcept;
Effects: Returns the number of elements that can be inserted at the back without allocating additional memory.
Throws: Nothing.
Complexity: Constant.
Note: Non-standard extension.
iterator begin() noexcept;
Effects: Returns an iterator to the first element contained in the container.
Throws: Nothing.
Complexity: Constant.
const_iterator begin() const noexcept;
Effects: Returns a const_iterator to the first element contained in the container.
Throws: Nothing.
Complexity: Constant.
iterator end() noexcept;
Effects: Returns an iterator to the end of the container.
Throws: Nothing.
Complexity: Constant.
const_iterator end() const noexcept;
Effects: Returns a const_iterator to the end of the container.
Throws: Nothing.
Complexity: Constant.
reverse_iterator rbegin() noexcept;
Effects: Returns a reverse_iterator pointing to the beginning of the reversed container.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator rbegin() const noexcept;
Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed container.
Throws: Nothing.
Complexity: Constant.
reverse_iterator rend() noexcept;
Effects: Returns a reverse_iterator pointing to the end of the reversed container.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator rend() const noexcept;
Effects: Returns a const_reverse_iterator pointing to the end of the reversed container.
Throws: Nothing.
Complexity: Constant.
const_iterator cbegin() const noexcept;
Effects: Returns a const_iterator to the first element contained in the container.
Throws: Nothing.
Complexity: Constant.
const_iterator cend() const noexcept;
Effects: Returns a const_iterator to the end of the container.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator crbegin() const noexcept;
Effects: Returns a const_reverse_iterator pointing to the beginning of the reversed container.
Throws: Nothing.
Complexity: Constant.
const_reverse_iterator crend() const noexcept;
Effects: Returns a const_reverse_iterator pointing to the end of the reversed container.
Throws: Nothing.
Complexity: Constant.
bool empty() const noexcept;
Effects: Returns true if the container contains no elements.
Throws: Nothing.
Complexity: Constant.
size_type size() const noexcept;
Effects: Returns the number of the elements contained in the container.
Throws: Nothing.
Complexity: Constant.
size_type max_size() const noexcept;
Effects: Returns the largest possible size of the container.
Throws: Nothing.
Complexity: Constant.
reference front();
Requires: !empty()
Effects: Returns a reference to the first element of the container.
Throws: Nothing.
Complexity: Constant.
const_reference front() const;
Requires: !empty()
Effects: Returns a const reference to the first element from the beginning of the container.
Throws: Nothing.
Complexity: Constant.
reference back();
Requires: !empty()
Effects: Returns a reference to the last element of the container.
Throws: Nothing.
Complexity: Constant.
const_reference back() const;
Requires: !empty()
Effects: Returns a const reference to the last element of the container.
Throws: Nothing.
Complexity: Constant.
reference operator[](size_type n);
Requires: size() > n.
Effects: Returns a reference to the nth element from the beginning of the container.
Throws: Nothing.
Complexity: Constant.
const_reference operator[](size_type n) const;
Requires: size() > n.
Effects: Returns a const reference to the nth element from the beginning of the container.
Throws: Nothing.
Complexity: Constant.
reference at(size_type n);
Requires: size() > n.
Effects: Returns a reference to the nth element from the beginning of the container.
Throws: range_error if n >= size()
Complexity: Constant.
const_reference at(size_type n) const;
Requires: size() > n.
Effects: Returns a const reference to the nth element from the beginning of the container.
Throws: range_error if n >= size()
Complexity: Constant.
allocator_type get_allocator() const noexcept;
Effects: Returns a copy of the internal allocator.
Throws: If allocator's copy constructor throws.
Complexity: Constant.
const stored_allocator_type & get_stored_allocator() const noexcept;
Effects: Returns a reference to the internal allocator.
Throws: Nothing
Complexity: Constant.
Note: Non-standard extension.
stored_allocator_type & get_stored_allocator() noexcept;
Effects: Returns a reference to the internal allocator.
Throws: Nothing
Complexity: Constant.
Note: Non-standard extension.
void assign(size_type n, const value_type & value);
Effects: Assigns the n copies of val to *this.
Throws: If memory allocation throws or T's copy constructor throws.
Complexity: Linear to n.
template<typename InIt> void assign(InIt first, InIt last);
Effects: Assigns the range [first, last) to *this.
Throws: If memory allocation throws or T's constructor from dereferencing InIt throws.
Complexity: Linear to the distance [first, last).
void assign(std::initializer_list< value_type > il);
Effects: Assigns the range [il.begin(), il.end()) to *this.
Throws: If memory allocation throws or T's constructor from dereferencing std::initializer_list iterator throws.
Complexity: Linear to il.size().
void clear() noexcept;
Effects: Erases all the elements of the container.
Throws: Nothing.
Complexity: Linear to the number of elements in the container.
template<class... Args> iterator emplace(const_iterator p, Args &&... args);
Requires: p must be a valid iterator of *this.
Effects: Inserts an object of type T constructed with std::forward<Args>(args)... before p
Throws: If memory allocation throws or the in-place constructor throws.
Complexity: If p is end(), amortized constant time Linear time otherwise.
template<class... Args> reference emplace_back(Args &&... args);
Effects: Inserts an object of type T constructed with std::forward<Args>(args)... at the end of the container.
Returns: A reference to the created object.
Throws: If memory allocation throws or the in-place constructor throws.
Complexity: Amortized constant time
iterator insert(const_iterator p, const value_type & x);
Requires: p must be a valid iterator of *this.
Effects: Insert a copy of x before p.
Returns: an iterator to the inserted element.
Throws: If memory allocation throws or x's copy constructor throws.
Complexity: If p is end(), amortized constant time Linear time otherwise.
iterator insert(const_iterator p, value_type && x);
Requires: p must be a valid iterator of *this.
Effects: Insert a new element before p with x's resources.
Returns: an iterator to the inserted element.
Throws: If memory allocation throws.
Complexity: If p is end(), amortized constant time Linear time otherwise.
iterator insert(const_iterator pos, size_type n, const value_type & x);
Requires: pos must be a valid iterator of *this.
Effects: Insert n copies of x before pos.
Returns: an iterator to the first inserted element or pos if n is 0.
Throws: If memory allocation throws or T's copy constructor throws.
Complexity: Linear to n.
template<typename InIt> iterator iterator insert(const_iterator pos, InIt first, InIt last);
Requires: pos must be a valid iterator of *this.
Effects: Insert a copy of the [first, last) range before pos.
Returns: an iterator to the first inserted element or pos if first == last.
Throws: If memory allocation throws, T's constructor from a dereferenced InIt throws or T's copy constructor throws.
Complexity: Linear to distance [first, last).
iterator insert(const_iterator pos, std::initializer_list< value_type > il);
Requires: pos must be a valid iterator of *this.
Effects: Insert a copy of the [il.begin(), il.end()) range before pos.
Returns: an iterator to the first inserted element or pos if il.begin() == il.end().
Throws: If memory allocation throws, T's constructor from a dereferenced std::initializer_list throws or T's copy constructor throws.
Complexity: Linear to distance [il.begin(), il.end()).
iterator erase(const_iterator p) noexcept;
Effects: Erases the element at p.
Throws: Nothing.
Complexity: Linear to the elements between pos and the last element (if pos is near the end) or the first element if (pos is near the beginning). Constant if pos is the first or the last element.
iterator erase(const_iterator first, const_iterator last) noexcept;
Effects: Erases the elements pointed by [first, last).
Throws: Nothing.
Complexity: Linear to the distance between first and last plus the elements between pos and the last element (if pos is near the end) or the first element if (pos is near the beginning).
void push_back(const value_type & x);
Effects: Inserts a copy of x at the end of the container.
Throws: If memory allocation throws or T's copy constructor throws.
Complexity: Amortized constant time.
void push_back(value_type && x);
Effects: Constructs a new element at the end of the container and moves the resources of x to this new element.
Throws: If memory allocation throws.
Complexity: Amortized constant time.
void pop_back() noexcept;
Effects: Removes the last element from the container.
Throws: Nothing.
Complexity: Constant time.
void resize(size_type new_size);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are value initialized.
Throws: If memory allocation throws, or T's constructor throws.
Complexity: Linear to the difference between size() and new_size.
void resize(size_type new_size, default_init_t);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are default initialized.
Throws: If memory allocation throws, or T's constructor throws.
Complexity: Linear to the difference between size() and new_size.
Note: Non-standard extension
void resize(size_type new_size, const value_type & x);
Effects: Inserts or erases elements at the end such that the size becomes n. New elements are copy constructed from x.
Throws: If memory allocation throws, or T's copy constructor throws.
Complexity: Linear to the difference between size() and new_size.
void swap(segtor & x);
Effects: Swaps the contents of *this and x.
Throws: Nothing.
Complexity: Constant.
segtor public static functionsstatic size_type get_segment_size() noexcept;
Effects: Returns the number of continguous elements per segment/block. Same as get_block_size().
Throws: Nothing.
Complexity: Constant.
static size_type get_block_size() noexcept;
Effects: Returns the number of continguous elements per segment/block. Same as get_segment_size().
Throws: Nothing.
Complexity: Constant.
segtor friend functionsbool operator==(const segtor & x, const segtor & y);
Effects: Returns true if x and y are equal
Complexity: Linear to the number of elements in the container.
bool operator!=(const segtor & x, const segtor & y);
Effects: Returns true if x and y are unequal
Complexity: Linear to the number of elements in the container.
bool operator<(const segtor & x, const segtor & y);
Effects: Returns true if x is less than y
Complexity: Linear to the number of elements in the container.
bool operator>(const segtor & x, const segtor & y);
Effects: Returns true if x is greater than y
Complexity: Linear to the number of elements in the container.
bool operator<=(const segtor & x, const segtor & y);
Effects: Returns true if x is equal or less than y
Complexity: Linear to the number of elements in the container.
bool operator>=(const segtor & x, const segtor & y);
Effects: Returns true if x is equal or greater than y
Complexity: Linear to the number of elements in the container.
void swap(segtor & x, segtor & y);
Effects: x.swap(y)
Complexity: Constant.