DiaDes  0.1
DIAgnosis of Discrete-Event System
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
Diades::Utils::Selection< Item > Class Template Reference

#include <Selection.hh>

Classes

class  IndexIterator
 

Public Types

typedef vector< Item > ItemVector
 

Public Member Functions

 Selection (const vector< Item > &items)
 
IndexIterator indexBegin () const
 
IndexIterator indexEnd () const
 
unsigned numberOfNonSelectedItems () const
 
unsigned numberOfSelectedItems () const
 
unsigned numberOfItems () const
 
IndexIterator selectedIndexBegin () const
 
IndexIterator selectedIndexEnd () const
 
IndexIterator nonSelectedIndexBegin () const
 
IndexIterator nonSelectedIndexEnd () const
 
ItemVector::const_iterator selectedBegin () const
 
ItemVector::const_iterator selectedEnd () const
 
ItemVector::const_iterator nonSelectedBegin () const
 
ItemVector::const_iterator nonSelectedEnd () const
 
bool hasBeenAlreadySelectedOnce (unsigned index) const
 
bool allSelected () const
 
unsigned newSelection ()
 
const Item & getItem (unsigned index) const
 
void select (unsigned index)
 
void print ()
 

Private Attributes

const ItemVector_items
 
vector< unsigned > _unselectedItemPool
 
vector< unsigned > _position
 
unsigned _selectedIndexStart
 

Detailed Description

template<typename Item>
class Diades::Utils::Selection< Item >

A simple but efficient way to select items that were not selected before in a vector of items

Definition at line 30 of file Selection.hh.

Member Typedef Documentation

◆ ItemVector

template<typename Item>
typedef vector<Item> Diades::Utils::Selection< Item >::ItemVector

Definition at line 33 of file Selection.hh.

Constructor & Destructor Documentation

◆ Selection()

template<typename Item>
Diades::Utils::Selection< Item >::Selection ( const vector< Item > &  items)
inline

Unique constructor

Parameters
itemsthe vector of items that are under selection
Postcondition
none of them are selected
complexity linear in the size of the vector

Definition at line 107 of file Selection.hh.

Member Function Documentation

◆ allSelected()

template<typename Item>
bool Diades::Utils::Selection< Item >::allSelected ( ) const
inline
Returns
if any of the items in the vector has been selected once.
complexity: constant

Definition at line 307 of file Selection.hh.

◆ getItem()

template<typename Item>
const Item& Diades::Utils::Selection< Item >::getItem ( unsigned  index) const
inline
Parameters
indexindex of the item in the selection vector
Returns
the item of this index

Definition at line 337 of file Selection.hh.

◆ hasBeenAlreadySelectedOnce()

template<typename Item>
bool Diades::Utils::Selection< Item >::hasBeenAlreadySelectedOnce ( unsigned  index) const
inline

selection test

Parameters
indexIndex of an item in the vector
Returns
true is this item has been selected at least once before
complexity: constant

Definition at line 294 of file Selection.hh.

References Diades::Utils::Selection< Item >::_selectedIndexStart.

◆ indexBegin()

template<typename Item>
IndexIterator Diades::Utils::Selection< Item >::indexBegin ( ) const
inline

Iterator of the first index (selected or not)

Returns
Iterator of the first index
complexity: constant

Definition at line 127 of file Selection.hh.

References Diades::Utils::Selection< Item >::IndexIterator::IndexIterator().

◆ indexEnd()

template<typename Item>
IndexIterator Diades::Utils::Selection< Item >::indexEnd ( ) const
inline

Iterator on the element after the last index (selected or not)

Returns
Iterator on the element after the last index (selected or not)
complexity: constant

Definition at line 140 of file Selection.hh.

References Diades::Utils::Selection< Item >::IndexIterator::IndexIterator().

◆ newSelection()

template<typename Item>
unsigned Diades::Utils::Selection< Item >::newSelection ( )
inline

Get the index of an non-selected Item if such an item exists

Returns
the index of an non-selected Item if such an item exists, otherwise undefined. Mark this index as selected.
complexity: constant

Definition at line 322 of file Selection.hh.

References Diades::Utils::Selection< Item >::select().

◆ nonSelectedBegin()

template<typename Item>
ItemVector::const_iterator Diades::Utils::Selection< Item >::nonSelectedBegin ( ) const
inline

Iterator of the first non-selected item

Returns
Iterator of the first non-selected item
complexity: constant

Definition at line 267 of file Selection.hh.

◆ nonSelectedEnd()

template<typename Item>
ItemVector::const_iterator Diades::Utils::Selection< Item >::nonSelectedEnd ( ) const
inline

Iterator of the item after the last non-selected item

Returns
Iterator of the item after the last selected item
complexity: constant

Definition at line 280 of file Selection.hh.

References Diades::Utils::Selection< Item >::_selectedIndexStart.

◆ nonSelectedIndexBegin()

template<typename Item>
IndexIterator Diades::Utils::Selection< Item >::nonSelectedIndexBegin ( ) const
inline

Iterator of the first non selected index

Returns
Iterator of the first selected index
complexity: constant

Definition at line 215 of file Selection.hh.

References Diades::Utils::Selection< Item >::IndexIterator::IndexIterator().

◆ nonSelectedIndexEnd()

template<typename Item>
IndexIterator Diades::Utils::Selection< Item >::nonSelectedIndexEnd ( ) const
inline

Iterator on the index after the last non selected index

Returns
Iterator on the element after the last non selected index
complexity: constant

Definition at line 228 of file Selection.hh.

References Diades::Utils::Selection< Item >::IndexIterator::IndexIterator().

◆ numberOfItems()

template<typename Item>
unsigned Diades::Utils::Selection< Item >::numberOfItems ( ) const
inline

The number of items

Returns
the number of items

Definition at line 176 of file Selection.hh.

Referenced by Diades::Utils::Selection< Item >::numberOfSelectedItems().

◆ numberOfNonSelectedItems()

template<typename Item>
unsigned Diades::Utils::Selection< Item >::numberOfNonSelectedItems ( ) const
inline

The number of items not selected yet

Returns
number of items not selected yet

Definition at line 152 of file Selection.hh.

References Diades::Utils::Selection< Item >::_selectedIndexStart.

Referenced by Diades::Utils::Selection< Item >::numberOfSelectedItems().

◆ numberOfSelectedItems()

template<typename Item>
unsigned Diades::Utils::Selection< Item >::numberOfSelectedItems ( ) const
inline

The number of items already selected once

Returns
number of items already selected once

Definition at line 164 of file Selection.hh.

References Diades::Utils::Selection< Item >::numberOfItems(), and Diades::Utils::Selection< Item >::numberOfNonSelectedItems().

◆ print()

template<typename Item>
void Diades::Utils::Selection< Item >::print ( )
inline

print the internal state of the Selection object for debug only

Definition at line 365 of file Selection.hh.

References Diades::Utils::Selection< Item >::_selectedIndexStart.

◆ select()

template<typename Item>
void Diades::Utils::Selection< Item >::select ( unsigned  index)
inline

Set the item of this index selected

complexity: constant

Definition at line 348 of file Selection.hh.

References Diades::Utils::Selection< Item >::_selectedIndexStart.

Referenced by Diades::Utils::Selection< Item >::newSelection().

◆ selectedBegin()

template<typename Item>
ItemVector::const_iterator Diades::Utils::Selection< Item >::selectedBegin ( ) const
inline

Iterator of the first selected item

Returns
Iterator of the first selected item
complexity: constant

Definition at line 241 of file Selection.hh.

References Diades::Utils::Selection< Item >::_selectedIndexStart.

◆ selectedEnd()

template<typename Item>
ItemVector::const_iterator Diades::Utils::Selection< Item >::selectedEnd ( ) const
inline

Iterator of the item after the last selected item

Returns
Iterator of the item after the last selected item
complexity: constant

Definition at line 254 of file Selection.hh.

◆ selectedIndexBegin()

template<typename Item>
IndexIterator Diades::Utils::Selection< Item >::selectedIndexBegin ( ) const
inline

Iterator of the first selected index

Returns
Iterator of the first selected index
complexity: constant

Definition at line 189 of file Selection.hh.

References Diades::Utils::Selection< Item >::IndexIterator::IndexIterator().

◆ selectedIndexEnd()

template<typename Item>
IndexIterator Diades::Utils::Selection< Item >::selectedIndexEnd ( ) const
inline

Iterator on the index after the last selected index

Returns
Iterator on the element after the last selected index
complexity: constant

Definition at line 202 of file Selection.hh.

References Diades::Utils::Selection< Item >::IndexIterator::IndexIterator().

Member Data Documentation

◆ _items

template<typename Item>
const ItemVector& Diades::Utils::Selection< Item >::_items
private

Definition at line 37 of file Selection.hh.

◆ _position

template<typename Item>
vector<unsigned> Diades::Utils::Selection< Item >::_position
private

Definition at line 39 of file Selection.hh.

◆ _selectedIndexStart

template<typename Item>
unsigned Diades::Utils::Selection< Item >::_selectedIndexStart
private

◆ _unselectedItemPool

template<typename Item>
vector<unsigned> Diades::Utils::Selection< Item >::_unselectedItemPool
private

Definition at line 38 of file Selection.hh.


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