An adaptor for lazy insertions into a sparse table. More...
#include <ash/impl/sparse_group.h>
Public Types | |
typedef Table::value_type | value_type |
typedef Table::size_type | size_type |
typedef Table::reference | reference |
typedef Table::pointer | pointer |
Public Member Functions | |
table_element_adaptor (Table *tbl, size_type i) | |
Constructor. | |
reference | operator= (const value_type &val) |
Assignment from a value_type - insert the value. | |
operator value_type () | |
Cast to value_type. | |
pointer | operator& () |
Address operator. |
An adaptor for lazy insertions into a sparse table.
Table | The container type. |
A sparse table does not actually allocate memory for entries that are not filled. Because of this, it becomes complicated to have a non-const iterator: we don't know, if the iterator points to a not-filled bucket, whether you plan to fill it with something or whether you plan to read its value (in which case you'll get the default bucket value). Therefore, while we can define const operations in a pretty 'normal' way, for non-const operations, we define something that returns a helper object with operator= and operator& that allocate a bucket lazily. We use this for table[] and also for regular table iterators.
ash::table_element_adaptor< Table >::table_element_adaptor | ( | Table * | tbl, |
size_type | i | ||
) | [inline] |
Constructor.
tbl | A pointer to the container. |
i | The index of the element. |
ash::table_element_adaptor< Table >::operator value_type | ( | ) | [inline] |
Cast to value_type.
pointer ash::table_element_adaptor< Table >::operator& | ( | ) | [inline] |
Address operator.
reference ash::table_element_adaptor< Table >::operator= | ( | const value_type & | val | ) | [inline] |
Assignment from a value_type - insert the value.
© 2012 | Licensed under | Hosted by | Generated by 1.7.4 |