AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual > Class Template Reference

Class for manual memory management of neighbor lists. More...

#include <NeighborListsBuffer.h>

Public Member Functions

template<bool throwIfIndexOutOfBounds = false>
std::vector< Value > & getNeighborListRef (size_t index)
 Getter for a reference to a neighbor list by index.
 
template<bool throwIfKeyIsUnknown = false>
std::vector< Value > & getNeighborListRef (const Key &key)
 Getter for a reference to a neighbor list by key.
 
size_t getNewNeighborList ()
 Reserves a neighbor list for use.
 
size_t getNewNeighborList (const Key &key)
 Assigns a neighbor list to the given key.
 
void clear ()
 Clears the internal key map and moves _lastValidListIndex to indicate an empty buffer.
 
void reserveNeighborLists (size_t n)
 Resize the internal buffer so that there are new spare lists.
 
void setDefaultListLength (size_t defaultListLength)
 Set the initial length of new neighbor lists.
 
void setGrowthFactor (double growthFactor)
 Set the growth factor for the internal buffer.
 

Detailed Description

template<class Key, class Value, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
class autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >

Class for manual memory management of neighbor lists.

The key, value system behaves similar to a std::unordered_map, so see the official doc regarding these details.

A internal buffer of lists is kept in memory, never deleted, and only its content cleared and reassigned. Get access to new lists via the index returned from getNewNeighborList() and work on them via getNeighborListRef().

Template Parameters
KeyPreferably something that is cheap to destroy.
ValueHas to be default constructable.
Hash
KeyEqual

Member Function Documentation

◆ clear()

template<class Key , class Value , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
void autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >::clear ( )
inline

Clears the internal key map and moves _lastValidListIndex to indicate an empty buffer.

This function does not touch the buffer itself.

◆ getNeighborListRef() [1/2]

template<class Key , class Value , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
template<bool throwIfKeyIsUnknown = false>
std::vector< Value > & autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >::getNeighborListRef ( const Key &  key)
inline

Getter for a reference to a neighbor list by key.

Template Parameters
throwIfKeyIsUnknown
Parameters
key
Returns

◆ getNeighborListRef() [2/2]

template<class Key , class Value , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
template<bool throwIfIndexOutOfBounds = false>
std::vector< Value > & autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >::getNeighborListRef ( size_t  index)
inline

Getter for a reference to a neighbor list by index.

Template Parameters
throwIfIndexOutOfBounds
Parameters
index
Returns

◆ getNewNeighborList() [1/2]

template<class Key , class Value , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
size_t autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >::getNewNeighborList ( )
inline

Reserves a neighbor list for use.

Grows the internal buffer if there are no spare lists left.

Note
This function is NOT thread safe.
Returns
Index of the newly reserved list.

◆ getNewNeighborList() [2/2]

template<class Key , class Value , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
size_t autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >::getNewNeighborList ( const Key &  key)
inline

Assigns a neighbor list to the given key.

Note
This function is NOT thread safe.
Parameters
key
Returns
Index of the newly reserved list.

◆ reserveNeighborLists()

template<class Key , class Value , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
void autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >::reserveNeighborLists ( size_t  n)
inline

Resize the internal buffer so that there are new spare lists.

If n is not larger than the current capacity nothing happens.

Parameters
nNumber of lists to allocate space for.

◆ setDefaultListLength()

template<class Key , class Value , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
void autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >::setDefaultListLength ( size_t  defaultListLength)
inline

Set the initial length of new neighbor lists.

Parameters
defaultListLength

◆ setGrowthFactor()

template<class Key , class Value , class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
void autopas::NeighborListsBuffer< Key, Value, Hash, KeyEqual >::setGrowthFactor ( double  growthFactor)
inline

Set the growth factor for the internal buffer.

Parameters
growthFactor

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