SheafSystem  0.0.0.0
sheaf::index_iterator Class Reference

Iterates over the subset of Zn defined by the characteristic function host(). More...

#include <index_iterator.h>

Public Member Functions

 index_iterator ()
 Creates an instance with host() == 0. More...
 
 index_iterator (const zn_to_bool *xhost, const index_space_handle &xid_space, bool xdelete_host=false)
 Create an instance with host() == xhost and index.scope() == xid_space; if xdelete_host, delete host() when this is deleted. More...
 
virtual ~index_iterator ()
 Destructor; not virtual so this class should not be used as a base class. More...
 
const zn_to_boolhost () const
 The subset this is iterating over. More...
 
int item ()
 OBSOLETE: use index(). The current item in the subset. More...
 
const scoped_indexindex () const
 The current item in the subset. More...
 
bool is_done () const
 True if iteration finished. More...
 
bool is_last () const
 True if iteration finished after next call to next() More...
 
void next ()
 Makes item the next member of the subset. More...
 
void reset ()
 Restarts the iteration, makes item the first member of the subset. More...
 
virtual void reset (const zn_to_bool *xhost, const index_space_handle &xid_space, bool xdelete_host=false)
 Restarts the iteration on host xhost. More...
 

Protected Member Functions

void find_next_item ()
 Finds the next item in the iteration. More...
 

Protected Attributes

const zn_to_bool_host
 The subset this is iterating over. More...
 
bool _delete_host
 True if _host should be deleted when this is deleted. More...
 
int _word_index
 The index of the word containing the current bit. More...
 
int _word_ub
 The upper bound for the word index. More...
 
unsigned int _word
 The current word. More...
 
int _bit_index
 The index of the current bit. More...
 
int _bit_ub
 The upper bound on the bit index. More...
 
int _item
 The current item in the iteration. More...
 
int _next_item
 The next item in the iteration. More...
 
int _item_ub
 The upper bound in item. More...
 
scoped_index _index
 The current index in the iteration. More...
 

Detailed Description

Iterates over the subset of Zn defined by the characteristic function host().

Definition at line 39 of file index_iterator.h.

Constructor & Destructor Documentation

◆ index_iterator() [1/2]

sheaf::index_iterator::index_iterator ( )

Creates an instance with host() == 0.

Postcondition

Definition at line 29 of file index_iterator.cc.

References _bit_index, _bit_ub, _delete_host, _host, _item, _item_ub, _next_item, _word, _word_index, _word_ub, and is_done().

◆ index_iterator() [2/2]

sheaf::index_iterator::index_iterator ( const zn_to_bool xhost,
const index_space_handle xid_space,
bool  xdelete_host = false 
)

Create an instance with host() == xhost and index.scope() == xid_space; if xdelete_host, delete host() when this is deleted.

Precondition
  • xhost != 0
Hack:
host should be a reference counted pointer; see destructor.

Definition at line 59 of file index_iterator.cc.

References reset(), and ~index_iterator().

◆ ~index_iterator()

sheaf::index_iterator::~index_iterator ( )
virtual

Destructor; not virtual so this class should not be used as a base class.

Hack:
host should be a reference counted pointer.
Todo:
convert _host to reference counted pointer and remove _delete_host member. (Requires zn_to_bool inherit rc_any.)

Definition at line 78 of file index_iterator.cc.

References _delete_host, _host, and host().

Referenced by index_iterator().

Member Function Documentation

◆ find_next_item()

void sheaf::index_iterator::find_next_item ( )
inlineprotected

Finds the next item in the iteration.

Precondition
  • !is_done()
Postcondition
  • (_next_item < _item_ub) ? (*host())[_next_item] : true

Definition at line 220 of file index_iterator.cc.

References _bit_index, _bit_ub, _item_ub, _next_item, _word_index, _word_ub, host(), is_done(), and next().

Referenced by is_last(), next(), and reset().

◆ host()

const sheaf::zn_to_bool * sheaf::index_iterator::host ( ) const

The subset this is iterating over.

Definition at line 108 of file index_iterator.cc.

References _host, and item().

Referenced by find_next_item(), index(), item(), next(), reset(), and ~index_iterator().

◆ index()

◆ is_done()

◆ is_last()

bool sheaf::index_iterator::is_last ( ) const

True if iteration finished after next call to next()

Postcondition

Definition at line 197 of file index_iterator.cc.

References _item, _item_ub, _next_item, find_next_item(), is_done(), and next().

Referenced by is_done(), and sheaf::subposet_member_iterator::is_last().

◆ item()

int sheaf::index_iterator::item ( )

OBSOLETE: use index(). The current item in the subset.

Precondition
  • !is_done()
Postcondition
  • (*host())[result]

Definition at line 116 of file index_iterator.cc.

References _item, host(), index(), and is_done().

Referenced by sheaf::dof_tuple_record_set::compute_ext_id(), host(), next(), and reset().

◆ next()

◆ reset() [1/2]

void sheaf::index_iterator::reset ( )

Restarts the iteration, makes item the first member of the subset.

Precondition
Postcondition
  • !is_done() ? (*host())[item()] : true

Definition at line 292 of file index_iterator.cc.

References _bit_index, _bit_ub, _item, _next_item, _word_index, find_next_item(), host(), is_done(), item(), and next().

Referenced by sheaf::namespace_poset::clear(), index_iterator(), next(), sheaf::subposet_member_iterator::reset(), and reset().

◆ reset() [2/2]

void sheaf::index_iterator::reset ( const zn_to_bool xhost,
const index_space_handle xid_space,
bool  xdelete_host = false 
)
virtual

Restarts the iteration on host xhost.

Precondition
  • xhost != 0
Hack:
host should be a reference counted pointer; see destructor.
Postcondition
  • !is_done() ? (*host())[_item] : true

Definition at line 322 of file index_iterator.cc.

References _bit_ub, _delete_host, _host, _index, _item, _item_ub, _word_ub, host(), is_done(), sheaf::scoped_index::put_scope(), and reset().

Member Data Documentation

◆ _bit_index

int sheaf::index_iterator::_bit_index
protected

The index of the current bit.

Definition at line 131 of file index_iterator.h.

Referenced by find_next_item(), index_iterator(), and reset().

◆ _bit_ub

int sheaf::index_iterator::_bit_ub
protected

The upper bound on the bit index.

Definition at line 136 of file index_iterator.h.

Referenced by find_next_item(), index_iterator(), and reset().

◆ _delete_host

bool sheaf::index_iterator::_delete_host
protected

True if _host should be deleted when this is deleted.

Definition at line 111 of file index_iterator.h.

Referenced by index_iterator(), reset(), and ~index_iterator().

◆ _host

const zn_to_bool* sheaf::index_iterator::_host
protected

The subset this is iterating over.

Definition at line 106 of file index_iterator.h.

Referenced by host(), index_iterator(), reset(), and ~index_iterator().

◆ _index

scoped_index sheaf::index_iterator::_index
mutableprotected

The current index in the iteration.

Definition at line 161 of file index_iterator.h.

Referenced by index(), and reset().

◆ _item

int sheaf::index_iterator::_item
protected

The current item in the iteration.

Definition at line 141 of file index_iterator.h.

Referenced by index(), index_iterator(), is_done(), is_last(), item(), next(), and reset().

◆ _item_ub

int sheaf::index_iterator::_item_ub
protected

The upper bound in item.

Definition at line 151 of file index_iterator.h.

Referenced by find_next_item(), index_iterator(), is_done(), is_last(), next(), and reset().

◆ _next_item

int sheaf::index_iterator::_next_item
protected

The next item in the iteration.

Definition at line 146 of file index_iterator.h.

Referenced by find_next_item(), index_iterator(), is_last(), next(), and reset().

◆ _word

unsigned int sheaf::index_iterator::_word
protected

The current word.

Definition at line 126 of file index_iterator.h.

Referenced by index_iterator().

◆ _word_index

int sheaf::index_iterator::_word_index
protected

The index of the word containing the current bit.

Definition at line 116 of file index_iterator.h.

Referenced by find_next_item(), index_iterator(), and reset().

◆ _word_ub

int sheaf::index_iterator::_word_ub
protected

The upper bound for the word index.

Definition at line 121 of file index_iterator.h.

Referenced by find_next_item(), index_iterator(), and reset().


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