PrevUpHomeNext

Struct template segmented_vector

boost::text::segmented_vector

Synopsis

// In header: <boost/text/segmented_vector.hpp>

template<typename T, typename Segment> 
struct segmented_vector : public boost::stl_interfaces::sequence_container_interface< segmented_vector< T, Segment >, boost::stl_interfaces::element_layout::discontiguous >
{
  // types
  typedef T                                                                                                                                           value_type;            
  typedef T *                                                                                                                                         pointer;               
  typedef T const *                                                                                                                                   const_pointer;         
  typedef value_type const &                                                                                                                          reference;             
  typedef reference                                                                                                                                   const_reference;       
  typedef std::size_t                                                                                                                                 size_type;             
  typedef std::ptrdiff_t                                                                                                                              difference_type;       
  typedef unspecified                                                                                                                                 iterator;              
  typedef iterator                                                                                                                                    const_iterator;        
  typedef stl_interfaces::reverse_iterator< iterator >                                                                                                reverse_iterator;      
  typedef reverse_iterator                                                                                                                            const_reverse_iterator;
  typedef Segment                                                                                                                                     segment_type;          
  typedef boost::stl_interfaces::sequence_container_interface< segmented_vector< T, Segment >, boost::stl_interfaces::element_layout::discontiguous > base_type;             

  // construct/copy/destruct
  segmented_vector();
  explicit segmented_vector(size_type);
  explicit segmented_vector(size_type, T const &);
  template<typename Iter, typename Sentinel> segmented_vector(Iter, Sentinel);
  segmented_vector(std::initializer_list< T >);
  segmented_vector(segmented_vector const &) = default;
  segmented_vector(segmented_vector &&);
  segmented_vector & operator=(segmented_vector const &) = default;
  segmented_vector & operator=(segmented_vector &&);
  ~segmented_vector();

  // public member functions
  const_iterator begin();
  const_iterator end();
  size_type size() const;
  size_type max_size() const;
  void resize(size_type);
  void resize(size_type, T const &);
  template<typename Iter, typename Sentinel> void assign(Iter, Sentinel);
  template<typename Iter> void assign(size_type, T const &);
  template<typename... Args> const_reference emplace_front(Args &&...);
  template<typename... Args> const_reference emplace_back(Args &&...);
  template<typename... Args> 
    const_iterator emplace(const_iterator, Args &&...);
  template<typename Iter, typename Sentinel> 
    const_iterator insert(const_iterator, Iter, Sentinel);
  const_iterator insert(const_iterator, segment_type);
  const_iterator erase(const_iterator, const_iterator);
  void swap(segmented_vector &);
  bool equal_root(segmented_vector) const;
  segmented_vector & replace(const_iterator, T);
  segmented_vector & replace(const_iterator, const_iterator, segment_type);
  template<typename Iter, typename Sentinel> 
    segmented_vector & replace(const_iterator, const_iterator, Iter, Sentinel);
  template<typename Fn> void foreach_segment(Fn &&) const;
};

Description

A sequence container of T with discontiguous storage. Insertion and erasure are efficient at any position within the sequence, and copies of the entire container are extremely cheap. The elements are immutable. In order to "mutate" one, use the single-element overload of replace().

segmented_vector public construct/copy/destruct

  1. segmented_vector();

    Default ctor.

    Postconditions:

    size() == 0 && begin() == end()

  2. explicit segmented_vector(size_type n);
  3. explicit segmented_vector(size_type n, T const & x);
  4. template<typename Iter, typename Sentinel> 
      segmented_vector(Iter first, Sentinel last);
  5. segmented_vector(std::initializer_list< T > il);
  6. segmented_vector(segmented_vector const &) = default;
  7. segmented_vector(segmented_vector &&);
  8. segmented_vector & operator=(segmented_vector const &) = default;
  9. segmented_vector & operator=(segmented_vector &&);
  10. ~segmented_vector();

segmented_vector public member functions

  1. const_iterator begin();
  2. const_iterator end();
  3. size_type size() const;
  4. size_type max_size() const;
  5. void resize(size_type sz);
  6. void resize(size_type sz, T const & x);
  7. template<typename Iter, typename Sentinel> 
      void assign(Iter first, Sentinel last);
  8. template<typename Iter> void assign(size_type n, T const & x);
  9. template<typename... Args> const_reference emplace_front(Args &&... args);
  10. template<typename... Args> const_reference emplace_back(Args &&... args);
  11. template<typename... Args> 
      const_iterator emplace(const_iterator at, Args &&... args);
  12. template<typename Iter, typename Sentinel> 
      const_iterator insert(const_iterator at, Iter first, Sentinel last);
  13. const_iterator insert(const_iterator at, segment_type v);
  14. const_iterator erase(const_iterator first, const_iterator last);
  15. void swap(segmented_vector & other);
  16. bool equal_root(segmented_vector other) const;

    Returns true if *this and other contain the same root node pointer. This is useful when you want to check for equality between two segmented_vectors that are likely to have originated from the same initial segmented_vector, and may have since been mutated.

  17. segmented_vector & replace(const_iterator at, T t);

    Replaces the element at position at with t, by moving t.

    If *this hold the only reference to the underlying data, this is more efficient than calling erase() in combination with insert().

    Requires:

    begin() <= old_substr.begin() && old_substr.end() <= end()

  18. segmented_vector & 
    replace(const_iterator first, const_iterator last, segment_type v);

    Replaces the portion of *this delimited by [first, last) with the sequence of T from v by moving the contents of v.

    Requires:

    begin() <= old_substr.begin() && old_substr.end() <= end()

  19. template<typename Iter, typename Sentinel> 
      segmented_vector & 
      replace(const_iterator old_first, const_iterator old_last, Iter new_first, 
              Sentinel new_last);

    Replaces the portion of *this delimited by [old_first, old_last) with the T sequence [new_first, new_last).

    Requires:

    begin() <= old_substr.begin() && old_substr.end() <= end()

  20. template<typename Fn> void foreach_segment(Fn && f) const;

    Visits each segment s of *this and calls f(s). Each segment is a string_view. Depending of the operation performed on each segment, this may be more efficient than iterating over [begin(), end()).

    Requires:

    Fn is an invocable accepting an iterator and a sentinel.


PrevUpHomeNext