Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения

Boost.MultiIndex Documentation - Random access indices reference

Boost , , Boost.MultiIndex Documentation - Reference

Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Boost.MultiIndex Random access indices reference



Contents

Header "boost/multi_index/random_access_index_fwd.hpp" synopsis

namespace boost{
namespace multi_index{
// random_access index specifier
template<typename TagList=tag<> > struct random_access;
// indices
namespace detail{
template<implementation defined> class index class name implementation defined;
} // namespace boost::multi_index::detail
} // namespace boost::multi_index 
} // namespace boost

<random_access_index_fwd.hpp>предоставляет форвардные декларации для указателя индекса<random_access>и связанного с ниминдекса случайного доступакласса.

Header "boost/multi_index/random_access_index.hpp" synopsis

#include <initializer_list>
namespace boost{
namespace multi_index{
// random_access index specifier
template<typename TagList=tag<> > struct random_access;
// indices
namespace detail{
template<implementation defined> class index class name implementation defined;
// index comparison:
// OP is any of ==,<,!=,>,>=,<=
template<arg set 1,arg set 2>
bool operator OP(
  const index class name<arg set 1>& x,const index class name<arg set 2>& y);
// index specialized algorithms:
template<implementation defined>
void swap(index class name& x,index class name& y);
} // namespace boost::multi_index::detail
} // namespace boost::multi_index 
} // namespace boost

random_access index specifier

Этот указатель индекса позволяет вставитьиндекс случайного доступа.

template<typename TagList=tag<> > struct random_access;

Если это так, то<TagList>должно быть.<tag>.

Random access indices

Индексы случайного доступа представляют собой последовательности свободного порядка с постоянным временным позиционным доступом и итераторами случайного доступа. Элементы в индексе случайного доступа по умолчанию отсортированы в соответствии с их порядком вставки: это означает, что новые элементы, вставленные через другой индекс<multi_index_container>, прилагаются к концу индекса случайного доступа; кроме того, предусмотрены средства для дальнейшей перестановки элементов. Публичный интерфейс индексов случайного доступа включает в себя индексысеквенированных индексовс различиями в сложности операций, плюс дополнительные операции для позиционного доступа<operator[]>и<at()>и для обработки емкости. Действительность итераторов и ссылки на элементы сохраняются во всех операциях, независимо от состояния мощности.

За исключением случаев, когда отмечается или если соответствующий интерфейс не существует, индексы случайного доступа проверяют те же требования к контейнеру, что и<std::vector>, плюс требования к<std::list>конкретным операциям списка на[list.ops].. Некоторые из наиболее важных различий в отношении<std::vector>:

  • Поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно-поверхностно.
  • ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦ ¦
  • В вязь< [37] >, , , , , , , , , , , , , , , , , , . Это гибкая емантика, направленная на борьбу с ней< [37] >.
  • Элементарно [[Элементы]] [[Элементы]] [[Элементы]] [[Элементы]] [[Элементы]] [[Элементы]] [[Элементы]] [[Элементы]] [[Элементы]] [[Элементы]] [[Элементы]]] [[Элементы]] [[Элементы]] [[Элементы]]] [[Элементы]] [[Элементы]] [[Элементы]]] [[Элементы]] [[Элементы]]] [[Электронные материалы]] [[Электронные материалы]] [[Электронные материалы]] [[Электронные материалы]] [[Электронные материалы]] [[Электронные материалы]] [[Электронные материалы]] [[Электронные материалы]] [[Электронные материалы]] [[Электронные материалы]] [[Электрон
  • < [49] >и< [50] >< [50] >,< [50] >и< [50] >, [скрыто] и [скрыто], [скрыто] и [скрыто].
Индексы случайного доступа не обеспечивают смежность памяти и, следовательно, не имеютdataфункций-членов.
  • Сложность некоторых операций, в частности вставки и удаления, отличается от операцийstd::vector.
  • В отличие отstd::vector, вставки в индекс случайного доступа могут потерпеть неудачу из-за столкновений с другими индексами. Это изменяет семантику операций, предусмотренных по отношению к их аналогам вstd::vector.
  • Элементы в индексе доступа рандона не являются изменчивыми и могут быть изменены только с помощью функцийreplaceиmodifyчленов.
  • push_frontиpop_frontпредусмотрены для совместимости с секвенированными индексами, хотя для их выполнения требуется линейное время.
  • [ORIG_END] -->

    namespace boost{
    namespace multi_index{
    namespace detail{
    template<implementation defined: dependent on types Value, Allocator, TagList>
    class name is implementation defined
    { 
    public:
      // types:
      typedef Value                                      value_type;
      typedef boost::tuples::null_type                   ctor_args;
      typedef TagList                                    tag_list;
      typedef Allocator                                  allocator_type;
      typedef typename allocator_type::reference         reference;
      typedef typename allocator_type::const_reference   const_reference;
      typedef implementation defined                     iterator;
      typedef implementation defined                     const_iterator;
      typedef std::size_t                                size_type;      
      typedef std::ptrdiff_t                             difference_type;
      typedef typename allocator_type::pointer           pointer;
      typedef typename allocator_type::const_pointer     const_pointer;
      typedef equivalent to
        std::reverse_iterator<iterator>                  reverse_iterator;
      typedef equivalent to
        std::reverse_iterator<const_iterator>            const_reverse_iterator;
      // construct/copy/destroy:
      index class name& operator=(const index class name& x);
      index class name& operator=(std::initializer_list<value_type> list);
      template <class InputIterator>
      void assign(InputIterator first,InputIterator last);
      void assign(std::initializer_list<value_type> list)
      void assign(size_type n,const value_type& value);
        
      allocator_type get_allocator()const noexcept;
      // iterators:
      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;
      iterator       iterator_to(const value_type& x);
      const_iterator iterator_to(const value_type& x)const;
      // capacity:
      bool      empty()const noexcept;
      size_type size()const noexcept;
      size_type max_size()const noexcept;
      size_type capacity()const noexcept;
      void      reserve(size_type m);
      void      shrink_to_fit();
      void resize(size_type n);
      void resize(size_type n,const value_type& x);
      // access:
      const_reference operator[](size_type n)const;
      const_reference at(size_type n)const;
      const_reference front()const;
      const_reference back()const;
      // modifiers:
      template<typename... Args>
      std::pair<iterator,bool> emplace_front(Args&&... args);
      std::pair<iterator,bool> push_front(const value_type& x);
      std::pair<iterator,bool> push_front(value_type&& x);
      void                     pop_front();
      template<typename... Args>
      std::pair<iterator,bool> emplace_back(Args&&... args);
      std::pair<iterator,bool> push_back(const value_type& x);
      std::pair<iterator,bool> push_back(value_type&& x);
      void                     pop_back();
      template<typename... Args>
      std::pair<iterator,bool> emplace(iterator position,Args&&... args);
      std::pair<iterator,bool> insert(iterator position,const value_type& x);
      std::pair<iterator,bool> insert(iterator position,value_type&& x);
      void insert(iterator position,size_type m,const value_type& x);
      template<typename InputIterator>
      void insert(iterator position,InputIterator first,InputIterator last);
      void insert(iterator position,std::initializer_list<value_type> list);
      iterator erase(iterator position);
      iterator erase(iterator first,iterator last);
      bool replace(iterator position,const value_type& x);
      bool replace(iterator position,value_type&& x);
      template<typename Modifier> bool modify(iterator position,Modifier mod);
      template<typename Modifier,typename Rollback>
      bool modify(iterator position,Modifier mod,Rollback back);
      void swap(index class name& x);
      void clear()noexcept;
      // list operations:
      void splice(iterator position,index class name& x);
      void splice(iterator position,index class name& x,iterator i);
      void splice(
        iterator position,index class name& x,iterator first,iterator last);
      void remove(const value_type& value);
      template<typename Predicate> void remove_if(Predicate pred);
      void unique();
      template <class BinaryPredicate>
      void unique(BinaryPredicate binary_pred);
      void merge(index class name& x);
      template <typename Compare> void merge(index class name& x,Compare comp);
      void sort();
      template <typename Compare> void sort(Compare comp);
      void reverse()noexcept;
      // rearrange operations:
      void relocate(iterator position,iterator i); 
      void relocate(iterator position,iterator first,iterator last);
      template<typename InputIterator> void rearrange(InputIterator first);
    }
    // index comparison:
    template<arg set 1,arg set 2>
    bool operator==(
      const index class name<arg set 1>& x,
      const index class name<arg set 2>& y)
    {
      return x.size()==y.size()&&std::equal(x.begin(),x.end(),y.begin());
    }
    template<arg set 1,arg set 2>
    bool operator<(
      const index class name<arg set 1>& x,
      const index class name<arg set 2>& y)
    {
      return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end());
    }
    template<arg set 1,arg set 2>
    bool operator!=(
      const index class name<arg set 1>& x,
      const index class name<arg set 2>& y)
    {
      return !(x==y);
    }
    template<arg set 1,arg set 2>
    bool operator>(
      const index class name<arg set 1>& x
      ,const index class name<arg set 2>& y)
    {
      return y<x;
    }
    template<arg set 1,arg set 2>
    bool operator>=(
      const index class name<arg set 1>& x,
      const index class name<arg set 2>& y)
    {
      return !(x<y);
    }
    template<arg set 1,arg set 2>
    bool operator<=(
      const index class name<arg set 1>& x,
      const index class name<arg set 2>& y)
    {
      return !(x>y);
    }
    // index specialized algorithms:
    template<implementation defined>
    void swap(index class name& x,index class name& y);
    } // namespace boost::multi_index::detail
    } // namespace boost::multi_index 
    } // namespace boost
    

    Complexity signature

    Здесь и в описаниях операций индексов случайного доступа мы принимаем схему, изложенную в разделесигнатур сложности. Сигнатурой сложности индексов случайного доступа является:

    • копия:< [65] >,
    • < [67] >[скрыто], [скрыто]
    • < [69] >[< [69] >] — [< [69] >] — [< [69] >] — [[< [69] >].
    • < [71] >,< [72] >-< [72] >,< [72] >,< [71] >,< [72] >,< [72] >,< [72] >,< [72] >,< [72] >,< [72] >,< [72] >,< [72] >.
    • < [75] >[[[[]]] [[[[]]]]] [[[[[]]]]][[[[[]]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]][[[[[]]]]]][[[[]]]]][[[[[]]]]][[[[]]]]][[[[[]]]]][[[[]]]]]][[[[[[]]]]]][[[[]]]]][[[[]]]]][[[[]]]]]][[[[[]]]]][[[[]]]]][[[[[[]]]]][[[[]]]][[[[[]]]]]][[[[[[]]]]]][[[[]]]]][[[[]]]]][[[[]]]
    • < [77] >(постоянная).
    В качестве удобства для записи некоторых формул сложности используются следующие выражения:Копирование:c(n)=n*log(n),
  • вставка:i(n)=1(амортизированная постоянная),
  • h(n)=1(постоянная амортизация),
  • удаление:d(n)=m, гдеm- расстояние от удаленного элемента до конца последовательности,
  • Замена:r(n)=1(постоянная),
  • Изменить:m(n)=1(постоянно).
  • The following expressions are also used as a convenience for writing down some of the complexity formulas: [ORIG_END] -->

    shl(a,b) = a+b if a is nonzero, 0 otherwise.
    rel(a,b,c) = if a<b, c-a, else a-b,

    <shl>и<rel>обозначаютсменуиперемещениесоответственно.

    Instantiation types

    Индексы случайного доступа инстанцируются внутри<multi_index_container>и определяются с помощью<indexed_by>с<random_access>указателя индекса. Обоснования зависят от следующих типов:

    • < [86] >< [87] >,
    • < [90] >< [91] >,
    • < [94] >[deapartio slánda] (если это не так, то< [95] >].
    <TagList>должен быть моментом<tag>.Valueизmulti_index_container,
  • Allocatorизmulti_index_container,
  • TagListиз указателя индекса (если предусмотрено, в противном случаеtag<>предполагается).
  • TagList must be an instantiation of tag. [ORIG_END] -->

    Constructors, copy and assignment

    Как поясняется в разделеконцептов индексов, индексы не имеют публичных конструкторов или деструкторов. Присвоение, с другой стороны, предусмотрено.

    index class name& operator=(const index class name& x);
    Effects:
    a=b;
    
    where a and b are the multi_index_container objects to which *this and x belong, respectively.
    Returns: *this.
    index class name& operator=(std::initializer_list<value_type> list);
    Effects:
    a=list;
    
    where a is the multi_index_container object to which *this belongs.
    Returns: *this.
    template <class InputIterator>
    void assign(InputIterator first,InputIterator last);
    Effects:
    clear();
    insert(end(),first,last);
    
    void assign(std::initializer_list<value_type> list);
    Effects:
    assign(list.begin(),list.end());
    
    void assign(size_type n,const value_type& value);
    Effects:
    clear();
    for(size_type i=0;i<n;++n)push_back(v);
    

    Iterators

    iterator       iterator_to(const value_type& x);
    const_iterator iterator_to(const value_type& x)const;
    Requires: x is a reference to an element of the container.
    Returns: An iterator to x.
    Complexity: Constant.
    Exception safety: nothrow.

    Capacity operations

    size_type capacity()const noexcept;
    Returns: The total number of elements c such that, when size()<c, back insertions happen in constant time (the general case as described by i(n) is amortized constant time.)
    Note: Validity of iterators and references to elements is preserved in all insertions, regardless of the capacity status.
    void reserve(size_type m);
    Effects: If the previous value of capacity() was greater than or equal to m, nothing is done; otherwise, the internal capacity is changed so that capacity()>=m.
    Complexity: If the capacity is not changed, constant; otherwise O(n).
    Exception safety: If the capacity is not changed, nothrow; otherwise, strong.
    void shrink_to_fit();
    Effects: Reduces capacity() to size().
    Complexity: If the capacity is not changed, constant; otherwise O(n).
    Exception safety: If the capacity is not changed, nothrow; otherwise, strong.
    void resize(size_type n);
    void resize(size_type n,const value_type& x);
    Requires (first version): value_type is DefaultInsertable into multi_index_container.
    Requires (second version): value_type is CopyInsertable into multi_index_container.
    Effects: If size()<n, tries to append n-size() default-inserted elements (first version) or copies of x (second version) at the end of the index. If n<size(), erases the last size()-n elements.
    Note: If an expansion is requested, the size of the index is not guaranteed to be n after this operation (other indices may ban insertions.)

    Modifiers

    template<typename... Args>
    std::pair<iterator,bool> emplace_front(Args&&... args);
    Effects:
    emplace(begin(),std::forward<Args>(args)...);
    
    Returns: The return value is a pair p. p.second is true if and only if insertion took place. On successful insertion, p.first points to the element inserted; otherwise, p.first points to an element that caused the insertion to be banned. Note that more than one element can be causing insertion not to be allowed.
    std::pair<iterator,bool> push_front(const value_type& x);
    std::pair<iterator,bool> push_front(value_type&& x);
    Effects:
    insert(begin(),x);            // lvalue ref version
    insert(begin(),std::move(x)); // rvalue ref version
    
    Returns: The return value is a pair p. p.second is true if and only if insertion took place. On successful insertion, p.first points to the element inserted; otherwise, p.first points to an element that caused the insertion to be banned. Note that more than one element can be causing insertion not to be allowed.
    template<typename... Args>
    std::pair<iterator,bool> emplace_back(Args&&... args);
    Effects:
    emplace(end(),std::forward<Args>(args)...);
    
    Returns: The return value is a pair p. p.second is true if and only if insertion took place. On successful insertion, p.first points to the element inserted; otherwise, p.first points to an element that caused the insertion to be banned. Note that more than one element can be causing insertion not to be allowed.
    std::pair<iterator,bool> push_back(const value_type& x);
    std::pair<iterator,bool> push_back(value_type&& x);
    Effects:
    insert(end(),x);            // lvalue ref version
    insert(end(),std::move(x)); // rvalue ref version
    
    Returns: The return value is a pair p. p.second is true if and only if insertion took place. On successful insertion, p.first points to the element inserted; otherwise, p.first points to an element that caused the insertion to be banned. Note that more than one element can be causing insertion not to be allowed.
    template<typename... Args>
    std::pair<iterator,bool> emplace(iterator position,Args&&... args);
    Requires: value_type is EmplaceConstructible into multi_index_container from args.
    Effects: Inserts a value_type object constructed with std::forward<Args>(args)... before position if insertion is allowed by all other indices of the multi_index_container.
    Returns: The return value is a pair p. p.second is true if and only if insertion took place. On successful insertion, p.first points to the element inserted; otherwise, p.first points to an element that caused the insertion to be banned. Note that more than one element can be causing insertion not to be allowed.
    Complexity: O(I(n)).
    Exception safety: Strong.
    std::pair<iterator,bool> insert(iterator position,const value_type& x);
    std::pair<iterator,bool> insert(iterator position,value_type&& x);
    Requires (first version): value_type is CopyInsertable into multi_index_container. position is a valid iterator of the index.
    Requires (second version): value_type is MoveInsertable into multi_index_container. position is a valid iterator of the index.
    Effects: Inserts x before position if insertion is allowed by all other indices of the multi_index_container.
    Returns: The return value is a pair p. p.second is true if and only if insertion took place. On successful insertion, p.first points to the element inserted; otherwise, p.first points to an element that caused the insertion to be banned. Note that more than one element can be causing insertion not to be allowed.
    Complexity: O(I(n)).
    Exception safety: Strong.
    void insert(iterator position,size_type m,const value_type& x);
    Requires: position is a valid iterator of the index.
    Effects:
    for(size_type i=0;i<m;++i)insert(position,x);
    
    Complexity: O(shl(end()-position,m) + m*I(n+m)).
    template<typename InputIterator>
    void insert(iterator position,InputIterator first,InputIterator last);
    Requires: position is a valid iterator of the index. InputIterator is an input iterator. value_type is EmplaceConstructible into multi_index_container from *first. first and last are not iterators into any index of the multi_index_container to which this index belongs. last is reachable from first.
    Effects: For each element of [first, last), in this order, inserts it before position if insertion is allowed by all other indices of the multi_index_container.
    Complexity: O(shl(end()-position,m) + m*I(n+m)), where m is the number of elements in [first,last).
    Exception safety: Basic.
    void insert(iterator position,std::initializer_list<value_type> list);
    Effects:
    insert(position,list.begin(),list.end());
    
    iterator erase(iterator position);
    Requires: position is a valid dereferenceable iterator of the index.
    Effects: Deletes the element pointed to by position.
    Returns: An iterator pointing to the element immediately following the one that was deleted, or end() if no such element exists.
    Complexity: O(D(n)).
    Exception safety: nothrow.
    iterator erase(iterator first,iterator last);
    Requires: [first,last) is a valid range of the index.
    Effects: Deletes the elements in [first,last).
    Returns: last.
    Complexity: O(m*D(n)), where m is the number of elements in [first,last).
    Exception safety: nothrow.
    bool replace(iterator position,const value_type& x);
    bool replace(iterator position,value_type&& x);
    Requires (first version): value_type is CopyAssignable. position is a valid dereferenceable iterator of the index.
    Requires (second version): value_type is MoveAssignable. position is a valid dereferenceable iterator of the index.
    Effects: Assigns the value x to the element pointed to by position into the multi_index_container to which the index belongs if replacing is allowed by all other indices of the multi_index_container.
    Postconditions: Validity of position is preserved in all cases.
    Returns: true if the replacement took place, false otherwise.
    Complexity: O(R(n)).
    Exception safety: Strong. If an exception is thrown by some user-provided operation the multi_index_container to which the index belongs remains in its original state.
    template<typename Modifier> bool modify(iterator position,Modifier mod);
    Requires: mod is a unary function object accepting arguments of type value_type&. position is a valid dereferenceable iterator of the index. The execution of mod(e), where e is the element pointed to by position, does not invoke any operation of the multi_index_container after e is directly modified or, before modification, if the operation would invalidate position.
    Effects: Calls mod(e) where e is the element pointed to by position and rearranges *position into all the indices of the multi_index_container. Rearrangement on sequenced indices does not change the position of the element with respect to the index; rearrangement on other indices may or might not succeed. If the rearrangement fails, the element is erased.
    Postconditions: Validity of position is preserved if the operation succeeds.
    Returns: true if the operation succeeded, false otherwise.
    Complexity: O(M(n)).
    Exception safety: Basic. If an exception is thrown by some user-provided operation (except possibly mod), then the element pointed to by position is erased.
    template<typename Modifier,typename Rollback>
    bool modify(iterator position,Modifier mod,Rollback back);
    Requires: mod and back are unary function objects accepting arguments of type value_type&. position is a valid dereferenceable iterator of the index. The execution of mod(e), where e is the element pointed to by position, does not invoke any operation of the multi_index_container after e is directly modified or, before modification, if the operation would invalidate position. back(e) does not invoke any operation of the multi_index_container. The sequence of operations mod(e), back(e) restores all keys of the element to their original state.
    Effects: Calls mod(e) where e is the element pointed to by position and tries to rearrange *position into all the indices of the multi_index_container. Rearrangement on sequenced indices does not change the position of the element with respect to the index; rearrangement on other indices may or might not succeed. If the rearrangement fails, back(e) is invoked and the element is kept at its original position in all indices.
    Postconditions: Validity of position is preserved except if the element is erased under the conditions described below.
    Returns: true if the operation succeeded, false otherwise.
    Complexity: O(M(n)).
    Exception safety: Strong, except if back throws an exception, in which case the modified element is erased. If back throws inside the handling code executing after some other user-provided operation has thrown, it is the exception generated by back that is rethrown.

    List operations

    Индексы случайного доступа повторяют интерфейс секвенированных индексов, который, в свою очередь, включает в себя операции списка, предоставляемые<std::list>. Синтаксис и поведение этих операций точно соответствуют секвенированным индексам, но связанные с ними границы сложности различаются в целом.

    void splice(iterator position,index class name& x);
    Requires: position is a valid iterator of the index. &x!=this.
    Effects: Inserts the contents of x before position, in the same order as they were in x. Those elements successfully inserted are erased from x.
    Complexity: O(shl(end()-position,x.size()) + x.size()*I(n+x.size()) + x.size()*D(x.size())).
    Exception safety: Basic.
    void splice(iterator position,index class name& x,iterator i);
    Requires: position is a valid iterator of the index. i is a valid dereferenceable iterator x.
    Effects: Inserts the element pointed to by i before position: if insertion is successful, the element is erased from x. In the special case &x==this, no copy or deletion is performed, and the operation is always successful. If position==i, no operation is performed.
    Postconditions: If &x==this, no iterator or reference is invalidated.
    Complexity: If &x==this, O(rel(position,i,i+1)); otherwise O(shl(end()-position,1) + I(n) + D(n)).
    Exception safety: If &x==this, nothrow; otherwise, strong.
    void splice(iterator position,index class name& x,iterator first,iterator last);
    Requires: position is a valid iterator of the index. first and last are valid iterators of x. last is reachable from first. position is not in the range [first,last).
    Effects: For each element in the range [first,last), insertion is tried before position; if the operation is successful, the element is erased from x. In the special case &x==this, no copy or deletion is performed, and insertions are always successful.
    Postconditions: If &x==this, no iterator or reference is invalidated.
    Complexity: If &x==this, O(rel(position,first,last)); otherwise O(shl(end()-position,m) + m*I(n+m) + m*D(x.size())) where m is the number of elements in [first,last).
    Exception safety: If &x==this, nothrow; otherwise, basic.
    void remove(const value_type& value);
    Effects: Erases all elements of the index which compare equal to value.
    Complexity: O(n + m*D(n)), where m is the number of elements erased.
    Exception safety: Basic.
    template<typename Predicate> void remove_if(Predicate pred);
    Effects: Erases all elements x of the index for which pred(x) holds.
    Complexity: O(n + m*D(n)), where m is the number of elements erased.
    Exception safety: Basic.
    void unique();
    Effects: Eliminates all but the first element from every consecutive group of equal elements referred to by the iterator i in the range [first+1,last) for which *i==*(i-1).
    Complexity: O(n + m*D(n)), where m is the number of elements erased.
    Exception safety: Basic.
    template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
    Effects: Eliminates all but the first element from every consecutive group of elements referred to by the iterator i in the range [first+1,last) for which binary_pred(*i,*(i-1)) holds.
    Complexity: O(n + m*D(n)), where m is the number of elements erased.
    Exception safety: Basic.
    void merge(index class name& x);
    Requires: std::less<value_type> induces a strict weak ordering over value_type. Both the index and x are sorted according to std::less<value_type>.
    Effects: Attempts to insert every element of x into the corresponding position of the index (according to the order). Elements successfully inserted are erased from x. The resulting sequence is stable, i.e. equivalent elements of either container preserve their relative position. In the special case &x==this, no operation is performed.
    Postconditions: Elements in the index and remaining elements in x are sorted. Validity of iterators to the index and of non-erased elements of x references is preserved.
    Complexity: If &x==this, constant; otherwise O(n + x.size()*I(n+x.size()) + x.size()*D(x.size())).
    Exception safety: If &x==this, nothrow; otherwise, basic.
    template <typename Compare> void merge(index class name& x,Compare comp);
    Requires: Compare induces a strict weak ordering over value_type. Both the index and x are sorted according to comp.
    Effects: Attempts to insert every element of x into the corresponding position of the index (according to comp). Elements successfully inserted are erased from x. The resulting sequence is stable, i.e. equivalent elements of either container preserve their relative position. In the special case &x==this, no operation is performed.
    Postconditions: Elements in the index and remaining elements in x are sorted according to comp. Validity of iterators to the index and of non-erased elements of x references is preserved.
    Complexity: If &x==this, constant; otherwise O(n + x.size()*I(n+x.size()) + x.size()*D(x.size())).
    Exception safety: If &x==this, nothrow; otherwise, basic.
    void sort();
    Requires: std::less<value_type> induces a strict weark ordering over value_type.
    Effects: Sorts the index according to std::less<value_type>. The sorting is stable, i.e. equivalent elements preserve their relative position.
    Postconditions: Validity of iterators and references is preserved.
    Complexity: O(n*log(n)).
    Exception safety: Basic.
    template <typename Compare> void sort(Compare comp);
    Requires: Compare induces a strict weak ordering over value_type.
    Effects: Sorts the index according to comp. The sorting is stable, i.e. equivalent elements preserve their relative position.
    Postconditions: Validity of iterators and references is preserved.
    Complexity: O(n*log(n)).
    Exception safety: Basic.
    void reverse()noexcept;
    Effects: Reverses the order of the elements in the index.
    Postconditions: Validity of iterators and references is preserved.
    Complexity: O(n).

    Rearrange operations

    Эти операции, не имеющие аналогов в STL-контейнерах последовательностей (хотя<std::list::splice>обеспечивает частично перекрывающуюся функциональность), выполняют индивидуальное и глобальное перепозиционирование элементов внутри индекса.

    void relocate(iterator position,iterator i);
    Requires: position is a valid iterator of the index. i is a valid dereferenceable iterator of the index.
    Effects: Inserts the element pointed to by i before position. If position==i, no operation is performed.
    Postconditions: No iterator or reference is invalidated.
    Complexity: O(rel(position,i,i+1)).
    Exception safety: nothrow.
    void relocate(iterator position,iterator first,iterator last);
    Requires: position is a valid iterator of the index. first and last are valid iterators of the index. last is reachable from first. position is not in the range [first,last).
    Effects: The range of elements [first,last) is repositioned just before position.
    Postconditions: No iterator or reference is invalidated.
    Complexity: O(rel(position,first,last)).
    Exception safety: nothrow.
    template<typename InputIterator> void rearrange(InputIterator first);
    Requires: The range [first, std::advance(first,n)), where n is the size of the index, is a free view of the index.
    Effects: The elements are rearranged so as to match the order of the previously described view.
    Postconditions: No iterator or reference is invalidated.
    Complexity: O(n).
    Exception safety: Basic.

    Serialization

    Индексы не могут быть сериализованы сами по себе, но только как часть<multi_index_container>, в которую они встроены. При описании дополнительных предварительных условий и гарантий, связанных с индексами случайного доступа в отношении сериализации их встраиваемых контейнеров, мы используем понятия, определенные в<multi_index_container>разделе сериализации.

    Operation: saving of a multi_index_container m to an output archive (XML archive) ar.
    Requires: No additional requirements to those imposed by the container.
    Operation: loading of a multi_index_container m' from an input archive (XML archive) ar.
    Requires: No additional requirements to those imposed by the container.
    Postconditions: On successful loading, each of the elements of [begin(), end()) is a restored copy of the corresponding element in [m.get<i>().begin(), m.get<i>().end()), where i is the position of the random access index in the container.
    Operation: saving of an iterator or const_iterator it to an output archive (XML archive) ar.
    Requires: it is a valid iterator of the index. The associated multi_index_container has been previously saved.
    Operation: loading of an iterator or const_iterator it' from an input archive (XML archive) ar.
    Postconditions: On successful loading, if it was dereferenceable then *it' is the restored copy of *it, otherwise it'==end().
    Note: It is allowed that it be a const_iterator and the restored it' an iterator, or viceversa.



    Пересмотрено 26 ноября 2015 года

    © Copyright 2003-2015 Joaquín M López Muñoz. Распространяется под лицензией Boost Software License, версия 1.0. (См. сопроводительный файлLICENSE_1_0.txtили копию на) http://www.boost.org/LICENSE_1_0.txt

    Статья Boost.MultiIndex Documentation - Random access indices reference раздела Boost.MultiIndex Documentation - Reference может быть полезна для разработчиков на c++ и boost.




    Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



    :: Главная :: Boost.MultiIndex Documentation - Reference ::


    реклама


    ©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
    Top.Mail.Ru

    Время компиляции файла: 2024-08-30 11:47:00
    2025-05-19 21:10:05/0.014232873916626/1