CatapultServer  v0.5.0.1 (Elephant)
catapult::state::CompactMosaicMap Class Reference
Inheritance diagram for catapult::state::CompactMosaicMap:
Collaboration diagram for catapult::state::CompactMosaicMap:

Classes

class  basic_iterator
 Base of mosaic iterators. More...
 
class  basic_iterator_t
 A basic typed iterator that adds support for dereferencing. More...
 
struct  FirstLevelStorage
 
struct  MosaicLocation
 
struct  MosaicUnion
 
struct  SecondLevelStorage
 

Public Types

using const_iterator = basic_iterator_t< const Mosaic >
 Mosaic const iterator. More...
 
using iterator = basic_iterator_t< Mosaic >
 Mosaic non-const iterator. More...
 

Public Member Functions

const_iterator begin () const
 Returns a const iterator to the first element of the underlying container. More...
 
const_iterator end () const
 Returns a const iterator to the element following the last element of the underlying container. More...
 
iterator begin ()
 Returns an iterator to the first element of the underlying container. More...
 
iterator end ()
 Returns an iterator to the element following the last element of the underlying container. More...
 
bool empty () const
 Returns true if the map is empty. More...
 
size_t size () const
 Gets the number of mosaics in the map. More...
 
const_iterator find (MosaicId id) const
 Finds the mosaic with id. More...
 
iterator find (MosaicId id)
 Finds the mosaic with id. More...
 
void insert (const Mosaic &pair)
 Inserts a mosaic pair. More...
 
void erase (MosaicId id)
 Erases the mosaic with id. More...
 
void optimize (MosaicId id)
 Optimizes access of the mosaic with id. More...
 

Private Types

enum  MosaicSource { MosaicSource::Value, MosaicSource::Array, MosaicSource::Map }
 
using Mosaic = std::pair< const MosaicId, Amount >
 
using MutableMosaic = std::pair< MosaicId, Amount >
 
using MosaicArray = std::array< MosaicUnion, Array_Size >
 
using MosaicMap = std::map< MosaicId, Amount >
 

Private Member Functions

bool find (MosaicId id, MosaicLocation &location) const
 
void insertIntoArray (size_t index, const Mosaic &pair)
 
void insertIntoMap (const Mosaic &pair)
 
void eraseFromArray (size_t index)
 
void compact ()
 
- Private Member Functions inherited from catapult::utils::MoveOnly
constexpr MoveOnly ()=default
 Default constructor. More...
 
 ~MoveOnly ()=default
 Default destructor. More...
 
 MoveOnly (const NonCopyable &)=delete
 Disabled copy constructor. More...
 
 MoveOnly (MoveOnly &&)=default
 Default move constructor. More...
 
MoveOnlyoperator= (const MoveOnly &)=delete
 Disabled assignment operator. More...
 
MoveOnlyoperator= (MoveOnly &&)=default
 Default move assignment operator. More...
 

Private Attributes

FirstLevelStorage m_storage
 
MosaicId m_optimizedMosaicId
 

Static Private Attributes

static constexpr auto Array_Size = 5
 

Detailed Description

A mosaic (ordered) map that is optimized for storage of a small number of elements.

Note
This map assumes that MosaicId(0) is not a valid mosaic.

Member Typedef Documentation

◆ const_iterator

◆ iterator

◆ Mosaic

using catapult::state::CompactMosaicMap::Mosaic = std::pair<const MosaicId, Amount>
private

◆ MosaicArray

◆ MosaicMap

◆ MutableMosaic

Member Enumeration Documentation

◆ MosaicSource

Enumerator
Value 
Array 
Map 

Member Function Documentation

◆ begin() [1/2]

CompactMosaicMap::iterator catapult::state::CompactMosaicMap::begin ( )

Returns an iterator to the first element of the underlying container.

◆ begin() [2/2]

CompactMosaicMap::const_iterator catapult::state::CompactMosaicMap::begin ( ) const

Returns a const iterator to the first element of the underlying container.

Here is the caller graph for this function:

◆ compact()

void catapult::state::CompactMosaicMap::compact ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

bool catapult::state::CompactMosaicMap::empty ( ) const

Returns true if the map is empty.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end() [1/2]

CompactMosaicMap::iterator catapult::state::CompactMosaicMap::end ( )

Returns an iterator to the element following the last element of the underlying container.

◆ end() [2/2]

CompactMosaicMap::const_iterator catapult::state::CompactMosaicMap::end ( ) const

Returns a const iterator to the element following the last element of the underlying container.

Here is the caller graph for this function:

◆ erase()

void catapult::state::CompactMosaicMap::erase ( MosaicId  id)

Erases the mosaic with id.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eraseFromArray()

void catapult::state::CompactMosaicMap::eraseFromArray ( size_t  index)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find() [1/3]

CompactMosaicMap::iterator catapult::state::CompactMosaicMap::find ( MosaicId  id)

Finds the mosaic with id.

Here is the call graph for this function:

◆ find() [2/3]

CompactMosaicMap::const_iterator catapult::state::CompactMosaicMap::find ( MosaicId  id) const

Finds the mosaic with id.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find() [3/3]

bool catapult::state::CompactMosaicMap::find ( MosaicId  id,
MosaicLocation location 
) const
private
Here is the call graph for this function:

◆ insert()

void catapult::state::CompactMosaicMap::insert ( const Mosaic pair)

Inserts a mosaic pair.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertIntoArray()

void catapult::state::CompactMosaicMap::insertIntoArray ( size_t  index,
const Mosaic pair 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insertIntoMap()

void catapult::state::CompactMosaicMap::insertIntoMap ( const Mosaic pair)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ optimize()

void catapult::state::CompactMosaicMap::optimize ( MosaicId  id)

Optimizes access of the mosaic with id.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

size_t catapult::state::CompactMosaicMap::size ( ) const

Gets the number of mosaics in the map.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Array_Size

constexpr auto catapult::state::CompactMosaicMap::Array_Size = 5
staticconstexprprivate

◆ m_optimizedMosaicId

MosaicId catapult::state::CompactMosaicMap::m_optimizedMosaicId
private

◆ m_storage

FirstLevelStorage catapult::state::CompactMosaicMap::m_storage
private

The documentation for this class was generated from the following files: