ROSE  0.9.10.6
Public Types | Public Member Functions | List of all members
Sawyer::Container::DistinctList< T, Cmp > Class Template Reference

Description

template<class T, class Cmp = std::less<T>>
class Sawyer::Container::DistinctList< T, Cmp >

A doubly-linked list of distinct items.

Each item on the list is unequal to any other item on the list. Most operations take O(log N) time.

Definition at line 24 of file DistinctList.h.

#include <DistinctList.h>

Inheritance diagram for Sawyer::Container::DistinctList< T, Cmp >:
Inheritance graph
[legend]

Public Types

typedef T Item
 
typedef Cmp Comparator
 
typedef std::list< Item > Items
 

Public Member Functions

 DistinctList ()
 Construct an empty list. More...
 
template<class T2 , class Cmp2 >
 DistinctList (const DistinctList< T2, Cmp2 > &other)
 Copy-construct a list. More...
 
template<class T2 , class Cmp2 >
DistinctListoperator= (const DistinctList< T2, Cmp2 > &other)
 Assign one list to another. More...
 
void clear ()
 Clear the list. More...
 
bool isEmpty () const
 Determines whether list is empty. More...
 
size_t size () const
 Number of items in list. More...
 
bool exists (const Item &item) const
 Determine if an item exists. More...
 
size_t position (const Item &item) const
 Determine the position of an item. More...
 
const Item & front () const
 Reference to item at front of list. More...
 
const Item & back () const
 Reference to item at back of list. More...
 
void pushFront (const Item &item)
 Insert item at front of list if distinct. More...
 
void pushBack (const Item &item)
 Insert item at back of list if distinct. More...
 
Item popFront ()
 Return and erase item at front of list. More...
 
Item popBack ()
 Return and erase item at back of list. More...
 
void erase (const Item &item)
 Erase an item from the list. More...
 
const Items & items () const
 Return all items as a list. More...
 

Constructor & Destructor Documentation

template<class T, class Cmp = std::less<T>>
Sawyer::Container::DistinctList< T, Cmp >::DistinctList ( )
inline

Construct an empty list.

Definition at line 37 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
template<class T2 , class Cmp2 >
Sawyer::Container::DistinctList< T, Cmp >::DistinctList ( const DistinctList< T2, Cmp2 > &  other)
inline

Copy-construct a list.

Definition at line 41 of file DistinctList.h.

Member Function Documentation

template<class T, class Cmp = std::less<T>>
template<class T2 , class Cmp2 >
DistinctList& Sawyer::Container::DistinctList< T, Cmp >::operator= ( const DistinctList< T2, Cmp2 > &  other)
inline

Assign one list to another.

Definition at line 48 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
void Sawyer::Container::DistinctList< T, Cmp >::clear ( )
inline

Clear the list.

Erase all items from the list making the list empty.

Definition at line 58 of file DistinctList.h.

Referenced by Sawyer::Container::DistinctList< size_t >::operator=(), and Rose::BinaryAnalysis::DataFlow::Engine< CFG, State, TransferFunction, MergeFunction, PathFeasibility >::reset().

template<class T, class Cmp = std::less<T>>
bool Sawyer::Container::DistinctList< T, Cmp >::isEmpty ( ) const
inline
template<class T, class Cmp = std::less<T>>
size_t Sawyer::Container::DistinctList< T, Cmp >::size ( void  ) const
inline

Number of items in list.

Returns the total number of items in the list in constant time.

Definition at line 73 of file DistinctList.h.

Referenced by Sawyer::Container::DistinctList< size_t >::position().

template<class T, class Cmp = std::less<T>>
bool Sawyer::Container::DistinctList< T, Cmp >::exists ( const Item &  item) const
inline

Determine if an item exists.

Returns true if the specified item exists in the list, false if not.

Definition at line 80 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
size_t Sawyer::Container::DistinctList< T, Cmp >::position ( const Item &  item) const
inline

Determine the position of an item.

Returns the position of an item from the beginning of the list. This is an O(n) operation.

Definition at line 87 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
const Item& Sawyer::Container::DistinctList< T, Cmp >::front ( ) const
inline

Reference to item at front of list.

Returns a const reference to the item at the front of the list, or throws an std::runtime_error if the list is empty.

Definition at line 103 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
const Item& Sawyer::Container::DistinctList< T, Cmp >::back ( ) const
inline

Reference to item at back of list.

Returns a const reference to the item at the back of the list, or throws an std::runtime_error if the list is empty.

Definition at line 113 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
void Sawyer::Container::DistinctList< T, Cmp >::pushFront ( const Item &  item)
inline

Insert item at front of list if distinct.

If item does not exist in the list then insert a copy at the front of the list. If the item exists then do nothing.

Definition at line 122 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
void Sawyer::Container::DistinctList< T, Cmp >::pushBack ( const Item &  item)
inline
template<class T, class Cmp = std::less<T>>
Item Sawyer::Container::DistinctList< T, Cmp >::popFront ( )
inline

Return and erase item at front of list.

Returns a copy of the item at the front of the list and that item is removed from the list. Throws an std::runtime_error if the list is empty.

Definition at line 145 of file DistinctList.h.

Referenced by Rose::BinaryAnalysis::DataFlow::Engine< CFG, State, TransferFunction, MergeFunction, PathFeasibility >::runOneIteration().

template<class T, class Cmp = std::less<T>>
Item Sawyer::Container::DistinctList< T, Cmp >::popBack ( )
inline

Return and erase item at back of list.

Returns a copy of the item at the back of the list and that item is removed from the list. Throws an std::runtime_error if the list is empty.

Definition at line 158 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
void Sawyer::Container::DistinctList< T, Cmp >::erase ( const Item &  item)
inline

Erase an item from the list.

Erases the item equal to item from the list if it exists, does nothing otherwise.

Definition at line 170 of file DistinctList.h.

template<class T, class Cmp = std::less<T>>
const Items& Sawyer::Container::DistinctList< T, Cmp >::items ( ) const
inline

Return all items as a list.

Returns all items as a list. The list is const since it should only be modified through this API.

Definition at line 181 of file DistinctList.h.

Referenced by Sawyer::Container::DistinctList< size_t >::DistinctList(), Sawyer::Container::DistinctList< size_t >::operator=(), and Rose::BinaryAnalysis::DataFlow::Engine< CFG, State, TransferFunction, MergeFunction, PathFeasibility >::runOneIteration().


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