jGL
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Attributes | List of all members
PriorityStore< T > Class Template Reference

Store elements in a priority ordering, with identities. More...

#include <priorityStore.h>

Classes

struct  Info
 Combine an id and a priority. More...
 

Public Member Functions

 PriorityStore (uint64_t sizeHint=8)
 Construct a new Priority Store with a reserved size.
 
virtual void clear ()
 
virtual void add (T s, ElementId id, Priority priority=0)
 Insert an element.
 
virtual void remove (ElementId id)
 
void updatePriority (ElementId id, Priority newPriority)
 
std::vector< std::pair< Info, T > > vectorise (std::multimap< Priority, ElementId > &oids)
 Return a vector from overriding priorities.
 
T & operator[] (ElementId id)
 
std::vector< std::pair< Info, T > >::const_iterator begin () const
 
std::vector< std::pair< Info, T > >::const_iterator end () const
 
uint64_t size () const
 
bool hasId (const ElementId id) const
 

Protected Attributes

std::unordered_map< ElementId, std::pair< T, Priority > > idToElement
 
std::vector< std::pair< Info, T > > cache
 

Detailed Description

template<class T>
class PriorityStore< T >

Store elements in a priority ordering, with identities.

Template Parameters
Tan element, wrapped in a std::shared_ptr.
Remarks
Elements are stored in a std::vector for effficient access.
Identities are stored for efficient lookup from string ids.

Constructor & Destructor Documentation

◆ PriorityStore()

template<class T >
PriorityStore< T >::PriorityStore ( uint64_t  sizeHint = 8)
inline

Construct a new Priority Store with a reserved size.

Parameters
sizeHintreserve this many elements.

Member Function Documentation

◆ add()

template<class T >
virtual void PriorityStore< T >::add ( s,
ElementId  id,
Priority  priority = 0 
)
inlinevirtual

Insert an element.

Parameters
sthe element.
idits identity.
priorityits priority.
Remarks
Throws std::runtime_error if the id already exists.

◆ begin()

template<class T >
std::vector< std::pair< Info, T > >::const_iterator PriorityStore< T >::begin ( ) const
inline

◆ clear()

template<class T >
virtual void PriorityStore< T >::clear ( )
inlinevirtual

◆ end()

template<class T >
std::vector< std::pair< Info, T > >::const_iterator PriorityStore< T >::end ( ) const
inline

◆ hasId()

template<class T >
bool PriorityStore< T >::hasId ( const ElementId  id) const
inline

◆ operator[]()

template<class T >
T & PriorityStore< T >::operator[] ( ElementId  id)
inline

◆ remove()

template<class T >
virtual void PriorityStore< T >::remove ( ElementId  id)
inlinevirtual

◆ size()

template<class T >
uint64_t PriorityStore< T >::size ( ) const
inline

◆ updatePriority()

template<class T >
void PriorityStore< T >::updatePriority ( ElementId  id,
Priority  newPriority 
)
inline

◆ vectorise()

template<class T >
std::vector< std::pair< Info, T > > PriorityStore< T >::vectorise ( std::multimap< Priority, ElementId > &  oids)
inline

Return a vector from overriding priorities.

Parameters
oidsoverriding priorities.
Returns
std::vector<std::pair<Info, T>> cached values.
Remarks
Overriding is expensive, but useful for drawing partially with modest element counts.

Member Data Documentation

◆ cache

template<class T >
std::vector<std::pair<Info, T> > PriorityStore< T >::cache
protected

◆ idToElement

template<class T >
std::unordered_map<ElementId, std::pair<T, Priority> > PriorityStore< T >::idToElement
protected

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