SheafSystem  0.0.0.0
sheaf::binary_index_block< T > Class Template Reference

A block which can be accessed using two indices, similarly to a two index array. More...

#include <binary_index_block.h>

Inheritance diagram for sheaf::binary_index_block< T >:
sheaf::block< T > sheaf::auto_block< T, un_block_initialization_policy< T > >

Public Member Functions

binary_index_blockoperator= (const binary_index_block &xother)
 Sets the contents of this to the contents of xother. More...
 
bool invariant () const
 
void push_back (const binary_index_block &xother)
 Appends xother to the back of this. More...
 
 binary_index_block (int xi_ub=0, int xj_ub=0)
 Default constructor. More...
 
 binary_index_block (const binary_index_block &xother)
 Copy constructor. More...
 
 binary_index_block (int xi_ub, int xi_ct, int xj_ub, int xj_ct, const T *xitems)
 Creates an instance with i_ub() == xi_ub and j_ub() == xj_ub containing xi_ct*xj_ct items copied from xitems. More...
 
 ~binary_index_block ()
 Destructor. More...
 
int i_ub () const
 The upper bound for the first index. More...
 
int j_ub () const
 The upper bound for the second index. More...
 
int i_ct () const
 The number of i index values currently in use. More...
 
int j_ct () const
 The number of j index values currently in use. More...
 
T & item (int xi, int xj)
 The item at index xi, xj (mutable version). More...
 
const T & item (int xi, int xj) const
 The item at index xi, xj (const version). More...
 
T * operator[] (int xi) const
 The address of the first item in row xi. /. More...
 
void force_item (int xi, int xj, const T &xitem)
 Puts the item xitem at index xi,xj, resizing if necessary. More...
 
void reserve (int xi_ub, int xj_ub)
 Makes i_ub() at least xi_ub and j_ub() at least xj_ub. More...
 
void set_ct (int xi_ct, int xj_ct)
 Sets i_ct() == xi_ct and j_ct() == xj_ct. More...
 
void put_item (int xi, int xj, const T &xitem)
 Sets the item xitem at index xi, xj to xitem, but will not resize. More...
 
void assign (const T &xitem)
 Sets the values of all items to xitem. More...
 
- Public Member Functions inherited from sheaf::block< T >
 block (index_type xub=0)
 Creates an instance with ub() == xub; storage is uninitialized. More...
 
 block (index_type xub, size_type xct, const T *xitems)
 Creates an instance with ub() == xub; storage is initialized with xct items copied from xitems. More...
 
 block (const block &xother)
 Copy constructor. More...
 
blockoperator= (const block &xother)
 Assignment operator. More...
 
 ~block ()
 Destructor. More...
 
- Public Member Functions inherited from sheaf::auto_block< T, un_block_initialization_policy< T > >
pointer_type base () const
 The underlying storage array. More...
 
size_type ct () const
 The number of items currently in use. More...
 
bool invariant () const
 The class invariant. More...
 
reference_type item (index_type xindex) const
 The item at index xindex. More...
 
reference_type operator[] (index_type xindex) const
 The item at index xindex. More...
 
index_type ub () const
 The upper bound on the storage array. The number of items current allocated in the storage array. More...
 
 auto_block (index_type xub=0)
 Creates an instance with ub() == xub; storage is uninitialized. More...
 
 auto_block (index_type xub, size_type xct, const T *xitems)
 Creates an instance with ub() == xub; storage is initialized with xct items copied from xitems. More...
 
 auto_block (const auto_block &xother)
 Copy constructor. More...
 
auto_blockoperator= (const auto_block &xother)
 Assignment operator. More...
 
virtual ~auto_block ()
 Destructor. More...
 
void force_item (index_type xindex, const_reference_type xitem)
 Puts the item xitem at index xindex, resizing if necessary; any other new storage allocated is uninitialized. More...
 
void reserve (index_type xub)
 Makes ub() at least xub; if new storage is allocated, it is uninitialized. More...
 
void set_ct (size_type xct)
 Sets ct() == xct. More...
 
void set_item (index_type xindex, const_reference_type xitem)
 Puts the item xitem at index xindex, but will not resize. More...
 
void assign (const_reference_type xitem)
 Sets the values of all items to xitem. More...
 
void assign (index_type xbegin, index_type xend, const_reference_type xitem)
 Sets the values of items with xbegin <= index < xend to xitem. More...
 
reference_type back () const
 The last item in the auto_block. More...
 
void push_back (const_reference_type item)
 Insert item at the end of the items in the auto_block. More...
 
void push_back (const auto_block &xother)
 Appends xother to the back of this. More...
 
void pop_back ()
 Remove item at the back. More...
 
void clear ()
 Remove all items. More...
 
void initialize (index_type xindex)
 Invokes the initialization policy on the item at xindex. More...
 
void initialize (index_type xbegin, index_type xend)
 Invokes the initialization policy on the range [xbegin, xend). More...
 

Protected Attributes

int _i_ub
 The upper bound for the first index. More...
 
int _j_ub
 The upper bound for the second index. More...
 
int _i_ct
 The number of i index values currently in use. More...
 
int _j_ct
 The number of j index values currently in use. More...
 
- Protected Attributes inherited from sheaf::auto_block< T, un_block_initialization_policy< T > >
pointer_type _base
 Start of storage for this. More...
 
index_type _ub
 The index upper bound. More...
 
size_type _ct
 The number of items currently stored. More...
 

Additional Inherited Members

- Public Types inherited from sheaf::block< T >
typedef auto_block< T, un_block_initialization_policy< T > > base_type
 
typedef base_type::index_type index_type
 
typedef base_type::size_type size_type
 
- Public Types inherited from sheaf::auto_block< T, un_block_initialization_policy< T > >
typedef T value_type
 The type of value stored in the container. More...
 
typedef un_block_initialization_policy< T > initialization_policy
 The value initialization policy. More...
 
typedef T & reference_type
 A type that behaves as a reference to the container's value type. More...
 
typedef const T & const_reference_type
 A type that behaves as a const reference to the container's value type. More...
 
typedef T * pointer_type
 A type that behaves as a pointer to the container's value type. More...
 
typedef const T * const_pointer_type
 A type that behaves as a const pointer to the container's value type. More...
 
typedef sheaf::pod_index_type index_type
 The containers index type. More...
 
typedef signed long int difference_type
 A signed integral type used to represent the difference of two indices or iterators. More...
 
typedef unsigned long int size_type
 An unsigned integral type used to represent sizes and capacities. More...
 

Detailed Description

template<typename T>
class sheaf::binary_index_block< T >

A block which can be accessed using two indices, similarly to a two index array.

Definition at line 39 of file binary_index_block.h.

Constructor & Destructor Documentation

◆ binary_index_block() [1/3]

template<typename T >
sheaf::binary_index_block< T >::binary_index_block ( int  xi_ub = 0,
int  xj_ub = 0 
)

Default constructor.

Precondition
  • xi_ub >= 0
  • xj_ub >= 0
Postcondition
  • this->ub() >= xi_ub*xj_ub
  • (xi_ub*xj_ub > 0) == (this->base() != 0)

Definition at line 127 of file binary_index_block.impl.h.

Referenced by sheaf::binary_index_block< T >::push_back(), and sheaf::binary_index_block< T >::~binary_index_block().

◆ binary_index_block() [2/3]

template<typename T >
sheaf::binary_index_block< T >::binary_index_block ( const binary_index_block< T > &  xother)

Copy constructor.

Precondition
  • precondition_of(block_xother)
Postcondition
  • postcondition_of(block(xother))

Definition at line 168 of file binary_index_block.impl.h.

References sheaf::block< T >::block(), and sheaf::binary_index_block< T >::~binary_index_block().

◆ binary_index_block() [3/3]

template<typename T >
sheaf::binary_index_block< T >::binary_index_block ( int  xi_ub,
int  xi_ct,
int  xj_ub,
int  xj_ct,
const T *  xitems 
)

◆ ~binary_index_block()

Member Function Documentation

◆ assign()

template<typename T >
void sheaf::binary_index_block< T >::assign ( const T &  xitem)

◆ force_item()

template<typename T >
void sheaf::binary_index_block< T >::force_item ( int  xi,
int  xj,
const T &  xitem 
)

Puts the item xitem at index xi,xj, resizing if necessary.

Precondition
  • 0 <= xi
  • 0 <= xj
Todo:
Fix the logic here.
Error:
we haven't guarded against overflow, nor have we ensured that an int is the proper thing to use to compute memory sizes.
Postcondition
  • item(xi, xj)==xitem

Definition at line 407 of file binary_index_block.impl.h.

References sheaf::binary_index_block< T >::_i_ub, sheaf::binary_index_block< T >::_j_ub, sheaf::binary_index_block< T >::invariant(), sheaf::binary_index_block< T >::item(), sheaf::binary_index_block< T >::put_item(), and sheaf::binary_index_block< T >::reserve().

Referenced by sheaf::binary_index_block< T >::operator[]().

◆ i_ct()

◆ i_ub()

◆ invariant()

◆ item() [1/2]

◆ item() [2/2]

template<typename T >
const T & sheaf::binary_index_block< T >::item ( int  xi,
int  xj 
) const

◆ j_ct()

◆ j_ub()

◆ operator=()

template<typename T >
binary_index_block< T > & sheaf::binary_index_block< T >::operator= ( const binary_index_block< T > &  xother)

Sets the contents of this to the contents of xother.

Definition at line 45 of file binary_index_block.impl.h.

References sheaf::binary_index_block< T >::invariant(), and sheaf::block< T >::operator=().

◆ operator[]()

template<typename T >
T * sheaf::binary_index_block< T >::operator[] ( int  xi) const

The address of the first item in row xi. /.

Issue:
with this operator, the expression b[i][j], / where b is a block should evaluate to the value of the item at i,j. / But what we really want is a reference to the item. / To do this we'll probably need some sort of intermediate type that / this operator can return, but then there may be efficiency issues. /
Precondition
Postcondition

Definition at line 382 of file binary_index_block.impl.h.

References sheaf::auto_block< T, un_block_initialization_policy< T > >::_base, sheaf::binary_index_block< T >::_j_ub, sheaf::binary_index_block< T >::force_item(), sheaf::binary_index_block< T >::i_ub(), and sheaf::binary_index_block< T >::invariant().

Referenced by sheaf::binary_index_block< T >::item().

◆ push_back()

template<typename T >
void sheaf::binary_index_block< T >::push_back ( const binary_index_block< T > &  xother)

Appends xother to the back of this.

Postcondition
  • this->ct() == old_ct + xother.ct()
  • for(int i = ( 0 ); i < ( xother.ct() ); ++ i ) ((*this)[i + old_ct] == xother[i])

Definition at line 97 of file binary_index_block.impl.h.

References sheaf::binary_index_block< T >::binary_index_block(), sheaf::auto_block< T, S >::ct(), and sheaf::binary_index_block< T >::item().

Referenced by sheaf::binary_index_block< T >::invariant().

◆ put_item()

template<typename T >
void sheaf::binary_index_block< T >::put_item ( int  xi,
int  xj,
const T &  xitem 
)

◆ reserve()

◆ set_ct()

template<typename T >
void sheaf::binary_index_block< T >::set_ct ( int  xi_ct,
int  xj_ct 
)

Member Data Documentation

◆ _i_ct

template<typename T >
int sheaf::binary_index_block< T >::_i_ct
protected

◆ _i_ub

◆ _j_ct

template<typename T >
int sheaf::binary_index_block< T >::_j_ct
protected

◆ _j_ub


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