40 #include "orbtree_base.h" 41 #include <type_traits> 48 #if __cplusplus >= 201703L 49 #define CONSTEXPR constexpr 79 template<
class NodeAllocator,
class Compare,
class NVFunc,
bool multi,
bool simple = false>
83 typedef typename orbtree_base<NodeAllocator, Compare, NVFunc, multi>::KeyValue KeyValue;
89 typedef typename NodeAllocator::KeyValue::ValueType
value_type;
91 typedef typename NodeAllocator::KeyValue::KeyType
key_type;
93 typedef typename NodeAllocator::NVType
NVType;
95 typedef size_t size_type;
96 typedef size_t difference_type;
100 explicit orbtree(
const NVFunc& f_ = NVFunc(),
const Compare& c_ = Compare())
101 :
orbtree_base<NodeAllocator, Compare, NVFunc, multi>(f_,c_) {
102 if CONSTEXPR (simple)
if(this->f.get_nr() != 1) {
103 throw std::runtime_error(
"For simple tree, weight function can only return one component!\n");
106 explicit orbtree(NVFunc&& f_,
const Compare& c_ = Compare())
108 if CONSTEXPR (simple)
if(this->f.get_nr() != 1) {
109 throw std::runtime_error(
"For simple tree, weight function can only return one component!\n");
113 explicit orbtree(
const T& t,
const Compare& c_ = Compare())
115 if CONSTEXPR (simple)
if(this->f.get_nr() != 1) {
116 throw std::runtime_error(
"For simple tree, weight function can only return one component!\n");
125 template<
bool is_const>
128 typedef typename NodeAllocator::KeyValue::ValueType value_base;
129 typedef typename std::conditional<is_const, const orbtree, orbtree>::type orbtree_t;
132 typedef std::bidirectional_iterator_tag iterator_category;
146 typedef const value_base* pointer;
147 typedef const value_base& reference;
150 friend class orbtree<NodeAllocator,Compare,NVFunc,multi,simple>;
158 template<
bool is_const_ = is_const>
160 :t(const_cast<
orbtree>(it.t)),n(it.n) { }
167 template<
bool is_const_ = is_const>
179 if(n == NodeAllocator::Invalid)
throw std::runtime_error(
"Attempt to dereference invalid orbtree::iterator!\n");
180 return t.get_node(n).get_key_value().keyvalue();
184 if(n == NodeAllocator::Invalid)
throw std::runtime_error(
"Attempt to dereference invalid orbtree::iterator!\n");
185 return &(t.get_node(n).get_key_value().keyvalue());
188 template<
bool is_const_ = is_const,
class KeyValue_ =
typename NodeAllocator::KeyValue>
189 typename std::enable_if<!is_const_>::type
set_value(
typename KeyValue_::MappedType&& v) {
190 t.update_value(n,std::move(v));
193 template<
bool is_const_ = is_const,
class KeyValue_ =
typename NodeAllocator::KeyValue>
194 typename std::enable_if<!is_const_>::type
set_value(
typename KeyValue_::MappedType
const& v) {
199 const key_type&
key()
const {
return t.get_node(n).get_key_value().key(); }
223 typedef typename std::conditional<NodeAllocator::KeyValue::keyonly, iterator_base<true>, iterator_base<false> >::type
iterator;
237 return NodeAllocator::max_nodes ? NodeAllocator::max_nodes : std::numeric_limits<size_t>::max();
246 typedef typename std::conditional<multi, iterator, std::pair<iterator, bool> >::type
insert_type;
249 template<
bool multi_ = multi>
250 typename std::enable_if<multi_,insert_type>::type insert_helper(
const value_type& v) {
253 template<
bool multi_ = multi>
254 typename std::enable_if<!multi_,insert_type>::type insert_helper(
const value_type& v) {
256 return std::pair<iterator,bool>(
iterator(*
this,x.first),x.second);
258 template<
bool multi_ = multi>
259 typename std::enable_if<multi_,insert_type>::type insert_helper(value_type&& v) {
262 template<
bool multi_ = multi>
263 typename std::enable_if<!multi_,insert_type>::type insert_helper(value_type&& v) {
265 return std::pair<iterator,bool>(
iterator(*
this,x.first),x.second);
269 template<
class... Args,
bool multi_ = multi>
270 typename std::enable_if<multi_,insert_type>::type emplace_helper(Args&... args) {
273 template<
class... Args,
bool multi_ = multi>
274 typename std::enable_if<!multi_,insert_type>::type emplace_helper(Args&... args) {
276 return std::pair<iterator,bool>(
iterator(*
this,x.first),x.second);
292 insert_type
insert(
const value_type& v) {
return insert_helper(v); }
294 insert_type
insert(value_type&& v) {
return insert_helper(std::move(v)); }
313 iterator
insert(const_iterator hint,
const value_type& v) {
318 iterator
insert(const_iterator hint, value_type&& v) {
330 template<
class... Args> insert_type
emplace(Args&&... args) {
return emplace_helper(std::forward<Args...>(args...)); }
332 template<
class... Args> iterator
emplace_hint(const_iterator hint, Args&&... args) {
343 if(first == last)
return iterator(*
this,first.n);
344 iterator x =
erase(first);
345 while(x != last) x =
erase(x);
359 size_t count(
const key_type& k)
const {
385 iterator
find(
const key_type& k) {
390 const_iterator
find(
const key_type& k)
const {
395 template<
class K> iterator
find(
const K& k) {
402 template<
class K> const_iterator
find(
const K& k)
const {
445 std::pair<const_iterator,const_iterator>
equal_range(
const key_type& k)
const {
449 template<
class K> std::pair<iterator,iterator>
equal_range(
const K& k) {
453 template<
class K> std::pair<const_iterator,const_iterator>
equal_range(
const K& k)
const {
462 template<
class K>
bool contains(
const K& k)
const {
475 template<
bool simple_ = simple>
476 void get_sum_node(const_iterator it,
typename std::enable_if<!simple_,NVType*>::type res)
const {
487 template<
bool simple_ = simple>
488 NVType
get_sum_node(
typename std::enable_if<simple_,const_iterator>::type it)
const {
502 template<
bool simple_ = simple>
503 void get_sum(
const key_type& k,
typename std::enable_if<!simple_,NVType*>::type res)
const {
513 template<
bool simple_ = simple>
514 NVType
get_sum(
typename std::enable_if<simple_,const key_type&>::type k)
const {
525 template<
class K,
bool simple_ = simple>
526 void get_sum(
const K& k,
typename std::enable_if<!simple_,NVType*>::type res)
const {
536 template<
class K,
bool simple_ = simple>
537 NVType
get_sum(
typename std::enable_if<simple_,const K&>::type k)
const {
543 template<
bool simple_ = simple>
546 template<
bool simple_ = simple> NVType
get_norm(
typename std::enable_if<simple_,void*>::type k = 0)
const {
563 template<
class NVFunc>
572 constexpr
unsigned int get_nr()
const {
return 1; }
581 void operator ()(
const typename NVFunc::argument_type& node_value, result_type* res)
const {
582 *res = f(node_value);
608 template<
class Key,
class NVFunc,
class Compare = std::less<Key> >
622 template<
class Key,
class NVFunc,
class Compare = std::less<Key> >
637 template<
class Key,
class NVFunc,
class Compare = std::less<Key> >
651 template<
class Key,
class NVFunc,
class Compare = std::less<Key> >
653 Compare, NVFunc_Adapter_Simple<NVFunc>,
true,
true >;
681 template<
class Key,
class NVFunc,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
711 template<
class Key,
class NVFunc,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
713 Compare, NVFunc_Adapter_Simple<NVFunc>,
false,
true >;
742 template<
class Key,
class NVFunc,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
772 template<
class Key,
class NVFunc,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
774 Compare, NVFunc_Adapter_Simple<NVFunc>,
true,
true >;
779 template<
class KeyValueType,
class NVType = u
int32_t>
struct RankFunc {
780 static_assert(std::is_integral<NVType>::value,
"rank variable must be integral!\n");
784 NVType operator ()(
const KeyValueType& k)
const {
return (NVType)1; }
785 typedef NVType result_type;
792 template<
class NVFunc>
796 const std::vector<typename NVFunc::ParType>
pars;
800 unsigned int get_nr()
const {
return pars.size(); }
802 void operator ()(
const typename NVFunc::argument_type& node_value, result_type* res)
const {
803 for(
size_t i=0;i<pars.size();i++) res[i] = f(node_value,pars[i]);
807 explicit NVFunc_Adapter_Vec(
const std::vector<typename NVFunc::ParType>& pars_,
const NVFunc& f_ = NVFunc()):f(f_),pars(pars_) { }
809 explicit NVFunc_Adapter_Vec(std::vector<typename NVFunc::ParType>&& pars_,
const NVFunc& f_ = NVFunc()):f(f_),pars(
std::move(pars_)) { }
811 explicit NVFunc_Adapter_Vec(
const std::vector<typename NVFunc::ParType>& pars_, NVFunc&& f_):f(
std::move(f_)),pars(pars_) { }
813 explicit NVFunc_Adapter_Vec(std::vector<typename NVFunc::ParType>&& pars_, NVFunc&& f_):f(
std::move(f_)),pars(
std::move(pars_)) { }
820 double operator () (
const KeyType& k,
double a)
const {
821 double x = (double)k;
835 double operator () (
const KeyType& k,
double a)
const {
836 double x = (double)(k.first);
837 double n = (double)(k.second);
859 template<
class Key,
class NVType = u
int32_t,
class Compare = std::less<Key> >
870 template<
class Key,
class NVType = u
int32_t,
class Compare = std::less<Key> >
872 NVFunc_Adapter_Simple<RankFunc<Key, NVType> >,
true,
true >;
888 template<
class Key,
class NVType = u
int32_t,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
890 NVFunc_Adapter_Simple<RankFunc<Key, NVType> >,
false,
true >;
906 template<
class Key,
class NVType = u
int32_t,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
908 NVFunc_Adapter_Simple<RankFunc<Key, NVType> >,
true,
true >;
928 template<
class NodeAllocator,
class Compare,
class NVFunc,
bool simple = false>
945 explicit orbtreemap(
const NVFunc& f_ = NVFunc(),
const Compare& c_ = Compare()) :
946 orbtree<NodeAllocator, Compare, NVFunc, false, simple>(f_,c_) { }
956 const mapped_type&
at(
const key_type& k)
const {
958 if(n == this->nil())
throw std::out_of_range(
"orbtreemap::at(): key not present in map!\n");
959 return get_node(n).get_key_value().value();
966 template<
class K>
const mapped_type&
at(
const K& k)
const {
968 if(n == this->nil())
throw std::out_of_range(
"orbtreemap::at(): key not present in map!\n");
969 return get_node(n).get_key_value().value();
980 return get_node(n).get_key_value().value();
987 bool set_value(
const key_type& k,
const mapped_type& v) {
989 if(tmp.second ==
false) tmp.first.set_value(v);
998 if(tmp.second ==
false) tmp.first.set_value(v);
1011 it.set_value(std::move(v));
1024 it.set_value(std::move(v));
1031 if(n == this->nil())
throw std::out_of_range(
"orbtreemap::at(): key not present in map!\n");
1037 if(n == this->nil())
throw std::out_of_range(
"orbtreemap::at(): key not present in map!\n");
1053 template<
class Key,
class Value,
class NVFunc,
class Compare = std::less<Key> >
1068 template<
class Key,
class Value,
class NVFunc,
class Compare = std::less<Key> >
1070 Compare, NVFunc_Adapter_Simple<NVFunc>,
true >;
1084 template<
class Key,
class Value,
class NVFunc,
class Compare = std::less<Key> >
1099 template<
class Key,
class Value,
class NVFunc,
class Compare = std::less<Key> >
1101 Compare, NVFunc_Adapter_Simple<NVFunc>,
true,
true>;
1124 template<
class Key,
class Value,
class NVFunc,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
1148 template<
class Key,
class Value,
class NVFunc,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
1150 Compare, NVFunc_Adapter_Simple<NVFunc>,
true >;
1172 template<
class Key,
class Value,
class NVFunc,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
1196 template<
class Key,
class Value,
class NVFunc,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
1198 Compare, NVFunc_Adapter_Simple<NVFunc>,
true,
true >;
1210 template<
class Key,
class Value,
class NVType,
class Compare = std::less<Key> >
1223 template<
class Key,
class Value,
class NVType,
class Compare = std::less<Key> >
1225 NVFunc_Adapter_Simple< RankFunc<NVType,KeyValue<Key,Value> > >,
true,
true >;
1245 template<
class Key,
class Value,
class NVType,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
1247 NVFunc_Adapter_Simple< RankFunc<NVType,KeyValue<Key,Value> > >,
true >;
1267 template<
class Key,
class Value,
class NVType,
class IndexType = u
int32_t,
class Compare = std::less<Key> >
1269 NVFunc_Adapter_Simple< RankFunc<NVType,KeyValue<Key,Value> > >,
true,
true >;
void update_value(const key_type &k, mapped_type &&v)
update the value of an existing element – throws exception if the key does not exist ...
Definition: orbtree.h:1035
const_iterator find(const key_type &k) const
iteraror that allows the modification of the stored value (for maps) find(const key_type& k) ...
Definition: orbtree.h:390
NVFunc_Adapter_Simple(const NVFunc &f_)
Create a new instance storing the given function.
Definition: orbtree.h:587
pointer operator->()
read-only access to values
Definition: orbtree.h:183
void insert(InputIt first, InputIt last)
insert all elements in the range [first,last)
Definition: orbtree.h:325
void get_sum_node(const_iterator it, typename std::enable_if<!simple_, NVType *>::type res) const
Calculate partial sum of the weights of nodes that come before the one pointed to by it...
Definition: orbtree.h:476
NodeHandle nil() const
handle of nil sentinel
Definition: orbtree_base.h:110
iterator lower_bound(const K &k)
return an iterator to the first element with key not less than k
Definition: orbtree.h:416
double ParType
exponent is double
Definition: orbtree.h:845
Order statistic multimap with compact storage, calculates the rank of elements. See orbtree for descr...
const_iterator end() const
get the past-the-end iterator
Definition: orbtree.h:230
void get_sum(const key_type &k, typename std::enable_if<!simple_, NVType *>::type res) const
Calculate partial sum of weights for keys that come before k.
Definition: orbtree.h:503
std::pair< const_iterator, const_iterator > equal_range(const K &k) const
return a pair of iterators corresponding to the range of all elements with keys that compares equal t...
Definition: orbtree.h:453
NVType get_sum(typename std::enable_if< simple_, const K &>::type k) const
Calculate partial sum of weights for keys that come before k.
Definition: orbtree.h:537
void update_value(NodeHandle n, typename KeyValue_::MappedType const &v)
update value in a node – only if this is a map; update sum recursively based on it as well ...
Definition: orbtree_base.h:273
bool set_value(const key_type &k, const mapped_type &v)
set value associated with the given key or insert new element
Definition: orbtree.h:987
iterator find(const key_type &k)
Find an element with the given key and return an iterator to it.
Definition: orbtree.h:385
KeyType argument_type
function argument is the key stored in the tree
Definition: orbtree.h:827
double ParType
exponent is double
Definition: orbtree.h:829
constexpr unsigned int get_nr() const
Dimension of result. In case of a simple function, it is one.
Definition: orbtree.h:572
bool operator==(const iterator_base< is_const2 > &i) const
compare iterators
Definition: orbtree.h:204
std::enable_if<!is_const_ >::type set_value(typename KeyValue_::MappedType const &v)
change value stored in map or multimap
Definition: orbtree.h:194
NodeAllocator::KeyValue::KeyType key_type
Key type of nodes that determines ordering.
Definition: orbtree.h:91
size_t count(const key_type &k) const
count number of elements with key
Definition: orbtree.h:359
Map implementation with compact storage. Simple version for weight functions that return one componen...
NVFunc_Adapter_Vec(std::vector< typename NVFunc::ParType > &&pars_, const NVFunc &f_=NVFunc())
this adapter can only be constructed with a parameter vector
Definition: orbtree.h:809
size_t count(const K &k) const
count the number of elements whose key compares equal to k
Definition: orbtree.h:367
const_iterator lower_bound(const K &k) const
return an iterator to the first element with key not less than k
Definition: orbtree.h:420
iterator upper_bound(const key_type &k)
return an iterator to the first element with key greater than k
Definition: orbtree.h:424
bool contains(const key_type &k) const
returns if an element with key equivalent to k exists in this tree
Definition: orbtree.h:458
Adapter for functions that return only one result. This class also describes the interface expected f...
Definition: orbtree.h:564
bool operator!=(const iterator_base< is_const2 > &i) const
compare iterators
Definition: orbtree.h:208
General map implementation. See orbtree and orbtreemap for description of members.
std::pair< iterator, iterator > equal_range(const K &k)
return a pair of iterators corresponding to the range of all elements with keys that compares equal t...
Definition: orbtree.h:449
NVFunc_Adapter_Vec(const std::vector< typename NVFunc::ParType > &pars_, const NVFunc &f_=NVFunc())
this adapter can only be constructed with a parameter vector
Definition: orbtree.h:807
iterator lower_bound(const key_type &k)
return an iterator to the first element with key not less than k
Definition: orbtree.h:408
iterator_base & operator++()
increment: move to the next stored node
Definition: orbtree.h:211
void get_norm(typename std::enable_if<!simple_, NVType *>::type res) const
Calculate normalization, i.e. sum of all weights. Equivalent to get_sum(cend(),res).
Definition: orbtree.h:544
NodeAllocator::NVType NVType
Type of values associated by nodes (calculated by NVFunc)
Definition: orbtree.h:93
bool set_value(key_type &&k, mapped_type &&v)
set value associated with the given key or insert new element
Definition: orbtree.h:1018
iterator find(const K &k)
iteraror that allows the modification of the stored value (for maps) find(const key_type& k) ...
Definition: orbtree.h:395
bool set_value(const key_type &k, mapped_type &&v)
set value associated with the given key or insert new element
Definition: orbtree.h:1005
iterator emplace_hint(const_iterator hint, Args &&... args)
construct new element in-place, using the given hint in a same way as insert() with a hint ...
Definition: orbtree.h:332
Generalized order statistic tree main interface. It is recommended to use the templates orbset...
Definition: orbtree.h:80
std::pair< NodeHandle, bool > emplace(T &&... t)
Construct new element in place.
const_iterator begin() const
get an iterator to the beginning (node with the lowest key value)
Definition: orbtree.h:226
General multiset, i.e. storing a collection of elements allowing duplicates. See orbtree for descript...
void get_sum_fv_node(NodeHandle x, NVType *res) const
get the generalized rank for a given node, i.e. the sum of NVFunv for all nodes before it in order ...
Definition: orbtree_base.h:419
NVFunc::result_type result_type
Type of the result of this function.
Definition: orbtree.h:566
KeyType argument_type
function argument is the key stored in the tree
Definition: orbtree.h:843
iterator_base & operator--()
decrement: move to the previous stored node
Definition: orbtree.h:215
Specialized set with compact storage. See orbtree for description of members.
const std::vector< typename NVFunc::ParType > pars
copy of the parameters
Definition: orbtree.h:796
void update_value(const key_type &k, const mapped_type &v)
update the value of an existing element – throws exception if the key does not exist ...
Definition: orbtree.h:1029
insert_type insert(const value_type &v)
Insert new element.
Definition: orbtree.h:292
General map implementation. Simple version for weight functions that return one component (i...
auto find(const K &key) const -> NodeHandle
find any node with the given key
Definition: orbtree_base.h:328
std::enable_if<!is_const_ >::type set_value(typename KeyValue_::MappedType &&v)
change value stored in map or multimap
Definition: orbtree.h:189
Specialized set with compact storage. Simple version for weight functions that return one component (...
const_iterator cbegin() const
get an iterator to the beginning (node with the lowest key value)
Definition: orbtree.h:227
NodeHandle last() const
get last node (or nil)
Definition: orbtree_base.h:475
General multiset, i.e. storing a collection of elements allowing duplicates. Simple version for weigh...
NVType get_sum_node(typename std::enable_if< simple_, const_iterator >::type it) const
Calculate partial sum of nodes that come before the one pointed to by it.
Definition: orbtree.h:488
iterator erase(const_iterator first, const_iterator last)
erase elements in the range [first,last); returns last
Definition: orbtree.h:342
iterator_base< true > const_iterator
iterator that does not allow modification
Definition: orbtree.h:221
Multimap implementation with compact storage. See orbtree for description of members.
const mapped_type & at(const key_type &k) const
Access mapped value for a given key, throws an exception if key is not found.
Definition: orbtree.h:956
const mapped_type & at(const K &k) const
Access mapped value for a key that compares equal to k, throws an exception if not such key is found...
Definition: orbtree.h:966
bool compare_key_equals(NodeHandle n, const KeyType &k) const
helper for erase to compare elements
Definition: orbtree_base.h:217
const mapped_type & operator[](const key_type &k)
Access mapped value for a given key, inserts a new element with the default value if not found...
Definition: orbtree.h:977
bool contains(const K &k) const
returns if an element with key equivalent to k exists in this tree
Definition: orbtree.h:462
iterator end()
get an iterator to the beginning (node with the lowest key value)
Definition: orbtree.h:229
size_t erase(const key_type &k)
erase all elements with the given key; returns the number of elements erased
Definition: orbtree.h:350
General multimap implementation (i.e. map allowing duplicate keys). Simple version for weight functio...
simple function to use for standard order statistic trees; returns 1 for any key, so sum of values ca...
Definition: orbtree.h:779
const_iterator lower_bound(const key_type &k) const
return an iterator to the first element with key not less than k
Definition: orbtree.h:412
NVFunc_Adapter_Vec(std::vector< typename NVFunc::ParType > &&pars_, NVFunc &&f_)
this adapter can only be constructed with a parameter vector
Definition: orbtree.h:813
NVFunc_Adapter_Vec(const std::vector< typename NVFunc::ParType > &pars_, NVFunc &&f_)
this adapter can only be constructed with a parameter vector
Definition: orbtree.h:811
NVFunc::result_type result_type
definition of result for the tree class to use
Definition: orbtree.h:798
size_t size1
keep track of the number of inserted elements
Definition: orbtree_base.h:85
std::conditional< NodeAllocator::KeyValue::keyonly, iterator_base< true >, iterator_base< false > >::type iterator
iteraror that allows the modification of the stored value (for maps)
Definition: orbtree.h:223
Order statistic set, calculates the rank of elements, compact version. See orbtree for description of...
Iterators.
Definition: orbtree.h:126
NodeHandle erase(NodeHandle n)
remove the given node – return the next node (i.e. next(n) before deleting n)
Definition: orbtree_base.h:828
std::pair< NodeHandle, bool > insert(ValueType &&kv)
Insert new element.
Definition: orbtree_base.h:687
bool empty() const
get the past-the-end iterator
Definition: orbtree.h:233
Map implementation with compact storage. See orbtree and orbtreemap for description of members...
std::pair< const_iterator, const_iterator > equal_range(const key_type &k) const
return a pair of iterators corresponding to the range of all elements with key equal to k ...
Definition: orbtree.h:445
KeyValueType argument_type
type of argument this function takes; same as the key / value type supplied
Definition: orbtree.h:780
const_iterator find(const K &k) const
iteraror that allows the modification of the stored value (for maps) find(const key_type& k) ...
Definition: orbtree.h:402
NodeAllocator::KeyValue::ValueType value_type
Values stored in this tree. Either the key (for sets) or an std::pair or orbtree::trivial_pair of key...
Definition: orbtree.h:89
Order statistic map, calculates the rank of elements. See orbtree and orbtreemap for description of m...
adapter for functions that take one parameter from a vector of parameters
Definition: orbtree.h:793
General set, i.e. storing a collection of elements without duplicates. Simple version for weight func...
unsigned int get_nr() const
number of component values returned is the same as the number of parameters
Definition: orbtree.h:800
reference operator*()
read-only access to values
Definition: orbtree.h:178
base class for both map and set – should not be used directly
Definition: orbtree_base.h:63
NodeHandle next(NodeHandle n) const
get node after n (or nil) – note: next(nil) == nil
Definition: orbtree_base.h:484
std::conditional< multi, iterator, std::pair< iterator, bool > >::type insert_type
return type of insert functions
Definition: orbtree.h:246
Multimap implementation with compact storage. Simple version for weight functions that return one com...
iterator insert(const_iterator hint, value_type &&v)
iteraror that allows the modification of the stored value (for maps) insert(const_iterator hint...
Definition: orbtree.h:318
Order statistic set, calculates the rank of elements. See orbtree for description of members...
insert_type emplace(Args &&... args)
construct new element in-place
Definition: orbtree.h:330
Order statistic multiset, calculates the rank of elements, compact version. See orbtree for descripti...
constexpr size_t max_size() const
return the maximum possible number of elements
Definition: orbtree.h:236
double result_type
result is double
Definition: orbtree.h:841
General set, i.e. storing a collection of elements without duplicates. See orbtree for description of...
Order statistic multiset, calculates the rank of elements.
double result_type
result is double
Definition: orbtree.h:825
const_iterator upper_bound(const key_type &k) const
return an iterator to the first element with key greater than k
Definition: orbtree.h:428
example function: key^, i.e. raise the key for a given power; version for a map, where the mapped val...
Definition: orbtree.h:833
const_iterator upper_bound(const K &k) const
return an iterator to the first element with key greater than k
Definition: orbtree.h:436
NodeHandle first() const
get first node (or nil)
Definition: orbtree_base.h:466
iterator insert(const_iterator hint, const value_type &v)
Insert new element with hint.
Definition: orbtree.h:313
void get_sum(const K &k, typename std::enable_if<!simple_, NVType *>::type res) const
Calculate partial sum of weights for keys that come before k.
Definition: orbtree.h:526
NVType get_sum(typename std::enable_if< simple_, const key_type &>::type k) const
Calculate partial sum of weights for keys that come before k.
Definition: orbtree.h:514
Order statistic map with compact storage, calculates the rank of elements. See orbtree and orbtreemap...
insert_type insert(value_type &&v)
Insert new element.
Definition: orbtree.h:294
Specialized multiset with compact storage. See orbtree for description of members.
std::pair< iterator, iterator > equal_range(const key_type &k)
return a pair of iterators corresponding to the range of all elements with key equal to k ...
Definition: orbtree.h:441
iterator erase(const_iterator pos)
erase element pointed to by the given iterator; returns the element after it (in order) ...
Definition: orbtree.h:340
size_t size() const
check if the tree is empty
Definition: orbtree.h:234
bool set_value(key_type &&k, const mapped_type &v)
set value associated with the given key or insert new element
Definition: orbtree.h:996
example function: key^, i.e. raise the key for a given power
Definition: orbtree.h:818
const value_base value_type
Type of value pointed to by iterator.
Definition: orbtree.h:145
General multimap implementation (i.e. map allowing duplicate keys). See orbtree for description of me...
NodeAllocator::KeyValue::MappedType mapped_type
type of values stored in this map
Definition: orbtree.h:943
const_iterator cend() const
get the past-the-end iterator
Definition: orbtree.h:231
iterator upper_bound(const K &k)
return an iterator to the first element with key greater than k
Definition: orbtree.h:432
const key_type & key() const
convenience function to return the key (for both set and map)
Definition: orbtree.h:199
Order statistic multimap, calculates the rank of elements. See orbtree for description of members...
void get_norm_fv(NVType *res) const
get the normalization factor, i.e. the sum of all keys
Definition: orbtree_base.h:452
Specialized multiset with compact storage. Simple version for weight functions that return one compon...
Base class with map-specific function. It is recommended to use the specializations simple_map...
Definition: orbtree.h:929
NodeAllocator::NodeHandle NodeHandle
handle to refer nodes to (pointer or integer)
Definition: orbtree_base.h:71
NVType get_norm(typename std::enable_if< simple_, void *>::type k=0) const
Calculate normalization, i.e. sum of all weights. Equivalent to get_sum(cend()).
Definition: orbtree.h:546