libStatGen Software 1
Loading...
Searching...
No Matches
LongCounter Class Reference
Inheritance diagram for LongCounter:
Collaboration diagram for LongCounter:

Public Member Functions

void IncrementCount (long long key)
void DecrementCount (long long key)
int GetCount (long long key)
Public Member Functions inherited from LongHash< int >
 LongHash (int startsize=32)
void Grow ()
void Shrink ()
void SetSize (int newsize)
void Clear ()
int Capacity () const
int Entries () const
int Object (int i) const
void SetObject (int i, int object)
unsigned int Add (long long key, int object)
unsigned int Find (long long key)
unsigned int Rehash (long long key, unsigned int h)
LongHashoperator= (const LongHash &rhs)
int operator[] (int i) const
void Delete (unsigned int index)
bool SlotInUse (int index) const
long long GetKey (int index) const
void SetAllowDuplicateKeys (bool toggle)

Additional Inherited Members

Protected Attributes inherited from LongHash< int >
int * objects
long long * keys
bool * occupancy
unsigned int count
unsigned int size
unsigned int mask
bool allowDuplicates

Detailed Description

Definition at line 23 of file LongLongCounter.h.

Constructor & Destructor Documentation

◆ LongCounter()

LongCounter::LongCounter ( )

Definition at line 20 of file LongLongCounter.cpp.

20 : LongHash<int>()
21{
22 SetAllowDuplicateKeys(false);
23}

Member Function Documentation

◆ DecrementCount()

void LongCounter::DecrementCount ( long long key)

Definition at line 37 of file LongLongCounter.cpp.

38{
39 unsigned int slot = Find(key);
40
41 if (slot == LH_NOTFOUND)
42 Add(key, -1);
43 else if (Object(slot) == 1)
44 Delete(slot);
45 else
46 Object(slot)--;
47}

◆ GetCount()

int LongCounter::GetCount ( long long key)

Definition at line 49 of file LongLongCounter.cpp.

50{
51 unsigned int slot = Find(key);
52
53 if (slot == LH_NOTFOUND)
54 return 0;
55 else
56 return Object(slot)--;
57}

◆ IncrementCount()

void LongCounter::IncrementCount ( long long key)

Definition at line 25 of file LongLongCounter.cpp.

26{
27 unsigned int slot = Find(key);
28
29 if (slot == LH_NOTFOUND)
30 Add(key, 1);
31 else if (Object(slot) == -1)
32 Delete(slot);
33 else
34 Object(slot)++;
35}

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