basis::set< contents > Class Template Reference

Emulates a mathematical set, providing several standard set operations. More...

#include <set.h>

Inheritance diagram for basis::set< contents >:

Inheritance graph
[legend]
Collaboration diagram for basis::set< contents >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 set (int num=0, const contents *init=NIL, u_short flags=array< contents >::EXPONE)
 Constructs a set with "num" elements, copying them from "init".
 ~set ()
 Destroys any storage held for the set.
int elements () const
 Returns the number of elements in this set.
bool empty () const
 Returns true if the set has no elements.
bool non_empty () const
 Returns true if the set has some elements.
void clear ()
 Empties out this set.
bool member (const contents &to_test) const
 Returns true if the item "to_test" is a member of this set.
bool add (const contents &to_add)
 Adds a new element "to_add" to the set.
setoperator+= (const contents &to_add)
 An algebraic operator synonym for add() that operates on the contents.
setoperator+= (const set &to_add)
 An algebraic operator synonym for add() that operates on a set.
bool remove (const contents &to_remove)
 Removes the item "to_remove" from the set.
setoperator-= (const contents &to_zap)
 An algebraic operator synonym for remove that operates on the contents.
setoperator-= (const set &to_zap)
 An algebraic operator synonym for remove that operates on a set.
set set_union (const set &union_with) const
 Implements the set union of "this" with "union_with".
void unionize (const set &union_with)
 Makes "this" set a union of "this" and "union_with".
set operator+ (const set &uw) const
 A synonym for set_union.
set intersection (const set &intersect_with) const
 Returns the intersection of "this" with the set in "intersect_with".
set operator * (const set &iw) const
 A synonym for intersection.
set difference (const set &differ_with) const
 Returns the difference of this with "differ_with".
void differentiate (const set &differ_with)
 Makes "this" set equal to the difference of "this" and "differ_with".
set operator- (const set &dw) const
 A synonym for difference.
int find (const contents &to_find) const
 Returns the integer index of the item "to_find" in this set.
bool remove_index (int index)
 Zaps the entry at the specified "index".

Detailed Description

template<class contents>
class basis::set< contents >

Emulates a mathematical set, providing several standard set operations.

Definition at line 29 of file set.h.


Constructor & Destructor Documentation

template<class contents>
basis::set< contents >::set ( int  num = 0,
const contents *  init = NIL,
u_short  flags = array<contents>::EXPONE 
) [inline]

Constructs a set with "num" elements, copying them from "init".

Be very careful to ensure that the array "init" has sufficient length for "num" elements to be copied from it.

Definition at line 35 of file set.h.

template<class contents>
basis::set< contents >::~set (  )  [inline]

Destroys any storage held for the set.

Definition at line 39 of file set.h.


Member Function Documentation

template<class contents>
int basis::set< contents >::elements (  )  const [inline]

Returns the number of elements in this set.

Definition at line 41 of file set.h.

Referenced by mailbox::apply(), pointer_hash< contents >::apply(), int_hash< contents >::apply(), config_watcher::changed_items(), config_watcher::changed_sections(), basis::set< contents >::difference(), basis::set< contents >::differentiate(), basis::set< istring >::empty(), basis::set< contents >::find(), basis::set< contents >::intersection(), process_manager::launch_now(), mailbox::limit_boxes(), basis::set< contents >::member(), basis::set< istring >::non_empty(), basis::pack(), buffer::references(), basis::set< contents >::remove(), basis::set< contents >::set_union(), mailbox::show(), symbol_table_compare(), system_values::text_form(), memory_limiter::text_form(), basis::set< contents >::unionize(), and process_manager::zap_process().

template<class contents>
bool basis::set< contents >::empty (  )  const [inline]

Returns true if the set has no elements.

Definition at line 44 of file set.h.

template<class contents>
bool basis::set< contents >::non_empty (  )  const [inline]

Returns true if the set has some elements.

Definition at line 46 of file set.h.

template<class contents>
void basis::set< contents >::clear (  )  [inline]

Empties out this set.

Definition at line 49 of file set.h.

Referenced by log_base::clear_filters(), process_control::find_process_in_list(), list_parsing::get_ids_from_string(), pointer_hash< contents >::reset(), int_hash< contents >::reset(), and basis::unpack().

template<class contents>
bool basis::set< contents >::member ( const contents &  to_test  )  const

Returns true if the item "to_test" is a member of this set.

Definition at line 25 of file set.cpp.

References basis::set< contents >::elements(), and this.

Referenced by basis::set< contents >::difference(), filter_actor_applier(), scheduler::filter_missing_actors(), socket_minder::handle_pending_connecters(), basis::set< contents >::intersection(), process_manager::launch_now(), log_base::member(), process_manager::push_timed_activities(), post_office::route_listed(), socket_minder::zap_pending_server(), and process_manager::zap_process().

template<class contents>
bool basis::set< contents >::add ( const contents &  to_add  ) 

Adds a new element "to_add" to the set.

This always succeeds, but will return true if the item was not already present.

Definition at line 34 of file set.cpp.

References array< contents >::concatenate(), and this.

Referenced by pointer_hash< contents >::add(), int_hash< contents >::add(), log_base::add_filter(), process_control::find_process_in_list(), list_parsing::get_ids_from_string(), basis::set< istring >::operator+=(), basis::set< contents >::set_union(), and basis::unpack().

template<class contents>
set& basis::set< contents >::operator+= ( const contents &  to_add  )  [inline]

An algebraic operator synonym for add() that operates on the contents.

Reimplemented from array< contents >.

Definition at line 59 of file set.h.

template<class contents>
set& basis::set< contents >::operator+= ( const set< contents > &  to_add  )  [inline]

An algebraic operator synonym for add() that operates on a set.

Definition at line 62 of file set.h.

template<class contents>
bool basis::set< contents >::remove ( const contents &  to_remove  ) 

Removes the item "to_remove" from the set.

If it was not present, false is returned and the set is unchanged.

Definition at line 51 of file set.cpp.

References basis::set< contents >::elements(), and this.

Referenced by pointer_hash< contents >::acquire(), int_hash< contents >::acquire(), pointer_hash< contents >::apply(), int_hash< contents >::apply(), basis::set< contents >::difference(), basis::set< istring >::operator-=(), log_base::remove_filter(), pointer_hash< contents >::zap(), int_hash< contents >::zap(), and socket_minder::zap_pending_server().

template<class contents>
set& basis::set< contents >::operator-= ( const contents &  to_zap  )  [inline]

An algebraic operator synonym for remove that operates on the contents.

Definition at line 70 of file set.h.

template<class contents>
set& basis::set< contents >::operator-= ( const set< contents > &  to_zap  )  [inline]

An algebraic operator synonym for remove that operates on a set.

Definition at line 73 of file set.h.

template<class contents>
set< contents > basis::set< contents >::set_union ( const set< contents > &  union_with  )  const

Implements the set union of "this" with "union_with".

This returns the set formed from the union of "this" set with the set specified in "union_with". (unfortunately, the name "set_union" must be used to distinguish from the C keyword "union".)

Definition at line 79 of file set.cpp.

References basis::set< contents >::add(), basis::set< contents >::elements(), and array< contents >::get().

Referenced by basis::set< istring >::operator+().

template<class contents>
void basis::set< contents >::unionize ( const set< contents > &  union_with  ) 

Makes "this" set a union of "this" and "union_with".

Definition at line 88 of file set.cpp.

References basis::set< contents >::elements(), array< contents >::get(), and this.

Referenced by basis::set< istring >::operator+=().

template<class contents>
set basis::set< contents >::operator+ ( const set< contents > &  uw  )  const [inline]

A synonym for set_union.

Definition at line 86 of file set.h.

template<class contents>
set< contents > basis::set< contents >::intersection ( const set< contents > &  intersect_with  )  const

Returns the intersection of "this" with the set in "intersect_with".

Definition at line 62 of file set.cpp.

References array< contents >::concatenate(), basis::set< contents >::elements(), array< contents >::get(), array< contents >::length(), basis::set< contents >::member(), NIL, and this.

Referenced by config_watcher::changed_items(), config_watcher::changed_sections(), and basis::set< istring >::operator *().

template<class contents>
set basis::set< contents >::operator * ( const set< contents > &  iw  )  const [inline]

A synonym for intersection.

Definition at line 92 of file set.h.

template<class contents>
set< contents > basis::set< contents >::difference ( const set< contents > &  differ_with  )  const

Returns the difference of this with "differ_with".

Difference is defined as the subset of elements in "this" that are not also in "differ_with".

Definition at line 95 of file set.cpp.

References basis::set< contents >::elements(), basis::set< contents >::member(), and basis::set< contents >::remove().

Referenced by basis::set< istring >::operator-().

template<class contents>
void basis::set< contents >::differentiate ( const set< contents > &  differ_with  ) 

Makes "this" set equal to the difference of "this" and "differ_with".

That is, after the call, "this" will only contain elements that were not also in "differ_with".

Definition at line 106 of file set.cpp.

References basis::set< contents >::elements(), and this.

Referenced by basis::set< istring >::operator-=().

template<class contents>
set basis::set< contents >::operator- ( const set< contents > &  dw  )  const [inline]

A synonym for difference.

Definition at line 105 of file set.h.

template<class contents>
int basis::set< contents >::find ( const contents &  to_find  )  const

Returns the integer index of the item "to_find" in this set.

This returns a negative number if the index cannot be found. Note that this only makes sense within our particular implementation of set as an array.

Definition at line 42 of file set.cpp.

References basis::set< contents >::elements(), common::NOT_FOUND, and this.

template<class contents>
bool basis::set< contents >::remove_index ( int  index  )  [inline]

Zaps the entry at the specified "index".

This also treats the set like an array. The index must be within the bounds of the existing members.

Definition at line 117 of file set.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 23 04:35:38 2008 for HOOPLE Libraries by  doxygen 1.5.1