OverSim
GiaKeyList Class Reference

This class is for managing (search)keys. More...

#include <GiaKeyList.h>

Public Member Functions

void addKeyItem (const OverlayKey &item)
 Add key-item to keyList.
void removeKeyItem (const OverlayKey &item)
 Removes key-item from keyList.
bool contains (const OverlayKey &item)
const std::vector< OverlayKey > & getVector ()
uint32_t getSize ()
const OverlayKeyget (uint32_t i)

Protected Member Functions

int getPosition (const OverlayKey &item)

Protected Attributes

std::vector< OverlayKeykeyList
 contains all search keys

Friends

std::ostream & operator<< (std::ostream &os, const GiaKeyList &k)

Detailed Description

This class is for managing (search)keys.

Definition at line 31 of file GiaKeyList.h.

Member Function Documentation

void GiaKeyList::addKeyItem ( const OverlayKey item)

Add key-item to keyList.

Parameters
itemto add

Definition at line 29 of file GiaKeyList.cc.

Referenced by Gia::handleAppMessage(), and Gia::handleUDPMessage().

{
if(!contains(item))
keyList.push_back(item);
}
bool GiaKeyList::contains ( const OverlayKey item)
Parameters
itemto check
Returns
true, if keylist contains item

Definition at line 42 of file GiaKeyList.cc.

Referenced by addKeyItem(), Gia::processSearchMessage(), and removeKeyItem().

{
if(getPosition(item) != -1)
return true;
return false;
}
const OverlayKey & GiaKeyList::get ( uint32_t  i)
Returns
element at position i

Definition at line 68 of file GiaKeyList.cc.

Referenced by Gia::sendKeyListToNeighbor().

{
return keyList[i];
}
int GiaKeyList::getPosition ( const OverlayKey item)
protected
Parameters
itemto get position
Returns
position of item in keylist, -1 if no item found

Definition at line 49 of file GiaKeyList.cc.

Referenced by contains(), and removeKeyItem().

{
for(uint32_t i = 0; i < keyList.size(); i++)
if(keyList[i] == item)
return i;
return -1;
}
uint32_t GiaKeyList::getSize ( )
Returns
size of keyList-vector

Definition at line 62 of file GiaKeyList.cc.

Referenced by Gia::addNeighbor(), Gia::handleTimerEvent(), and Gia::sendKeyListToNeighbor().

{
return keyList.size();
}
const std::vector< OverlayKey > & GiaKeyList::getVector ( )
Returns
vector of key

Definition at line 57 of file GiaKeyList.cc.

Referenced by Gia::handleAppMessage().

{
return keyList;
}
void GiaKeyList::removeKeyItem ( const OverlayKey item)

Removes key-item from keyList.

Parameters
itemto remove

Definition at line 35 of file GiaKeyList.cc.

{
std::vector<OverlayKey>::iterator it = keyList.begin();
if(contains(item))
keyList.erase(it + getPosition(item));
}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const GiaKeyList k 
)
friend

Definition at line 73 of file GiaKeyList.cc.

{
for ( uint32_t i = 0; i<k.keyList.size(); i++ )
os << k.keyList[i];
return os;
}

Member Data Documentation

std::vector<OverlayKey> GiaKeyList::keyList
protected

contains all search keys

Definition at line 70 of file GiaKeyList.h.

Referenced by addKeyItem(), getPosition(), getSize(), getVector(), operator<<(), and removeKeyItem().


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