Bitcoin ABC 0.30.7
P2P Digital Currency
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare > Class Template Reference

#include <shortidprocessor.h>

Inheritance diagram for ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >:
[legend]
Collaboration diagram for ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >:
[legend]

Public Member Functions

 ShortIdProcessor (const std::vector< PrefilledItemType > &prefilledItems, const std::vector< uint64_t > &shortids, size_t maxShortIdPerBucket)
 
bool isEvenlyDistributed () const
 Status accessors. More...
 
bool hasShortIdCollision () const
 
bool hasOutOfBoundIndex () const
 
size_t getItemCount () const
 Total item count. More...
 
size_t getShortIdCount () const
 Unique shortid count. More...
 
int matchKnownItem (uint64_t shortid, const ItemType &item)
 Attempts to add a known item by matching its shortid with the supplied ones. More...
 
const ItemTypegetItem (size_t index) const
 

Private Types

using ItemType = typename std::remove_reference< decltype(std::declval< Adapter & >().getItem(std::declval< PrefilledItemType & >()))>::type
 

Private Member Functions

int addItem (uint32_t index, const ItemType &item)
 

Private Attributes

bool evenlyDistributed = true
 
bool shortIdCollision = false
 
bool outOfBoundIndex = false
 
std::vector< ItemTypeitemsAvailable
 
std::vector< bool > haveItem
 
std::unordered_map< uint64_t, uint32_t > shortIdIndexMap
 

Detailed Description

template<typename PrefilledItemType, typename Adapter, typename ItemCompare>
class ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >

Definition at line 17 of file shortidprocessor.h.

Member Typedef Documentation

◆ ItemType

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
using ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::ItemType = typename std::remove_reference< decltype(std::declval<Adapter &>().getItem( std::declval<PrefilledItemType &>()))>::type
private

Definition at line 18 of file shortidprocessor.h.

Constructor & Destructor Documentation

◆ ShortIdProcessor()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::ShortIdProcessor ( const std::vector< PrefilledItemType > &  prefilledItems,
const std::vector< uint64_t > &  shortids,
size_t  maxShortIdPerBucket 
)
inline

Definition at line 55 of file shortidprocessor.h.

Here is the call graph for this function:

Member Function Documentation

◆ addItem()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
int ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::addItem ( uint32_t  index,
const ItemType item 
)
inlineprivate

Definition at line 30 of file shortidprocessor.h.

Here is the caller graph for this function:

◆ getItem()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
const ItemType & ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::getItem ( size_t  index) const
inline

Definition at line 118 of file shortidprocessor.h.

Here is the call graph for this function:

◆ getItemCount()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
size_t ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::getItemCount ( ) const
inline

Total item count.

Definition at line 92 of file shortidprocessor.h.

◆ getShortIdCount()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
size_t ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::getShortIdCount ( ) const
inline

Unique shortid count.

Definition at line 94 of file shortidprocessor.h.

◆ hasOutOfBoundIndex()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
bool ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::hasOutOfBoundIndex ( ) const
inline

Definition at line 89 of file shortidprocessor.h.

◆ hasShortIdCollision()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
bool ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::hasShortIdCollision ( ) const
inline

Definition at line 88 of file shortidprocessor.h.

◆ isEvenlyDistributed()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
bool ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::isEvenlyDistributed ( ) const
inline

Status accessors.

Definition at line 87 of file shortidprocessor.h.

◆ matchKnownItem()

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
int ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::matchKnownItem ( uint64_t  shortid,
const ItemType item 
)
inline

Attempts to add a known item by matching its shortid with the supplied ones.

The shortids must be processed prior from calling this method.

Parameters
[in]shortidThe shortid of the item
[in]itemThe item to be added, whose index is retrieved from its shortid
Returns
int The number of added items:
  • 0 if it was not added (e.g. index out of bounds).
  • +1 if added successfully.
  • -1 if an existing item was removed due to collision.

Definition at line 109 of file shortidprocessor.h.

Here is the call graph for this function:

Member Data Documentation

◆ evenlyDistributed

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
bool ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::evenlyDistributed = true
private

Definition at line 22 of file shortidprocessor.h.

◆ haveItem

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
std::vector<bool> ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::haveItem
private

Definition at line 27 of file shortidprocessor.h.

◆ itemsAvailable

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
std::vector<ItemType> ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::itemsAvailable
private

Definition at line 26 of file shortidprocessor.h.

◆ outOfBoundIndex

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
bool ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::outOfBoundIndex = false
private

Definition at line 24 of file shortidprocessor.h.

◆ shortIdCollision

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
bool ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::shortIdCollision = false
private

Definition at line 23 of file shortidprocessor.h.

◆ shortIdIndexMap

template<typename PrefilledItemType , typename Adapter , typename ItemCompare >
std::unordered_map<uint64_t, uint32_t> ShortIdProcessor< PrefilledItemType, Adapter, ItemCompare >::shortIdIndexMap
private

Definition at line 28 of file shortidprocessor.h.


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