PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc > Class Template Reference
Inheritance diagram for PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >:
[legend]
Collaboration diagram for PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >:
[legend]

## Public Member Functions

uint32_t | operator[] (uint32_t i)
void | set (uint32_t i, uint32_t v)
size_t | getElementCount () const
double | getUtilization ()
void | reserve (uint32_t reserveElements)
size_t | size ()
void | resize (uint32_t newSize)
void | push_back (uint32_t value)

## Protected Attributes

std::vector< uint8_t > | m_data
size_t | m_elementCount
double | m_growthRateMultiplier
double | m_growthRateAdder

## Detailed Description

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>
class PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >

Definition at line 41 of file PackedVector.h.

## Constructor & Destructor Documentation

## PackedVector()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::PackedVector | ( |  | ) |

inline

Definition at line 49 of file PackedVector.h.

:
m_elementCount(0),
m_growthRateMultiplier(1.20),
m_growthRateAdder(128) {;}

## Member Function Documentation

## getElementCount()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

size_t PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::getElementCount | ( |  | ) | const

inline

Definition at line 64 of file PackedVector.h.

{
return m_elementCount;
}

## getUtilization()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

double PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::getUtilization | ( |  | ) |

inline

Definition at line 69 of file PackedVector.h.

{
return elementCount2BytesFunc(m_elementCount) / (double) m_data.capacity();
}

## operator[]()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

uint32_t PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::operator[] | ( | uint32_t | i | ) |

inline

Definition at line 55 of file PackedVector.h.

{
return accessorFunc(m_data, i);
}

## push_back()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

void PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::push_back | ( | uint32_t | value | ) |

inline

Definition at line 85 of file PackedVector.h.

{
m_elementCount++;
if(elementCount2BytesFunc(m_elementCount) >= m_data.size()) {
if( (elementCount2BytesFunc(m_elementCount)) > m_data.capacity())
{
size_t newCapacity = (size_t) (m_data.capacity() * m_growthRateMultiplier);
// for small capacities, small fractional multipliers don't work,
// so we check and do a linear increase in those cases:
if(newCapacity == m_data.capacity()) {
newCapacity = (size_t) (m_data.capacity() + m_growthRateAdder);
}
m_data.reserve(newCapacity);
}
}
m_data.resize(elementCount2BytesFunc(m_elementCount));
set(m_elementCount-1, value);
}

## reserve()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

void PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::reserve | ( | uint32_t | reserveElements | ) |

inline

Definition at line 73 of file PackedVector.h.

{
m_data.reserve(elementCount2BytesFunc(reserveElements));
}

## resize()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

void PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::resize | ( | uint32_t | newSize | ) |

inline

Definition at line 79 of file PackedVector.h.

{
m_elementCount = newSize;
m_data.resize(elementCount2BytesFunc(m_elementCount));
}

## set()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

void PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::set | ( | uint32_t | i,
|  | uint32_t | v
| ) |  |

inline

Definition at line 59 of file PackedVector.h.

{
setterFunc(m_data, i, v);
}

## size()

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

size_t PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::size | ( |  | ) |

inline

Definition at line 77 of file PackedVector.h.

{return m_elementCount;}

## Member Data Documentation

## m_data

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

std::vector<uint8_t> PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::m_data

protected

Definition at line 44 of file PackedVector.h.

## m_elementCount

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

size_t PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::m_elementCount

protected

Definition at line 45 of file PackedVector.h.

## m_growthRateAdder

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

double PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::m_growthRateAdder

protected

Definition at line 47 of file PackedVector.h.

## m_growthRateMultiplier

template<uint32_t accessorFunc, void setterFunc, size_t elementCount2BytesFunc>

double PackedVector< accessorFunc, setterFunc, elementCount2BytesFunc >::m_growthRateMultiplier

protected

Definition at line 46 of file PackedVector.h.

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

- general/PackedVector.h