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

A two index array with variable length rows. More...

#include <ragged_array.h>

Inheritance diagram for sheaf::ragged_array< T >:
sheaf::rc_any sheaf::any

Friends

size_t deep_size (const ragged_array< T > &xra, bool xinclude_shallow)
 The deep size of the referenced object of type ragged_array<T>; if xinclude_shallow, add the sizeof xp to the result. More...
 

RAGGED_ARRAY FACET

typedef unsigned long index_type
 The integer type used to index this. More...
 
typedef rc_ptr< ragged_array< T > > ptr
 Reference counted pointer type. More...
 
block< T > _values
 The values stored in the array. More...
 
block< index_type_col_cts
 The number of columns in each row. More...
 
block< index_type_row_ptrs
 Index of the first value in each row. More...
 
 ragged_array (size_t xct=0)
 Default constructor; creates an empty array with one row and space reserved for xct values. More...
 
 ragged_array (const ragged_array &xother)
 Copy constructor. More...
 
 ragged_array (const index_type *xcol_cts, index_type xcol_cts_ub)
 Creates an instance with xrow_ct rows, with the number of columns in the i-th row given by xcol_cts[i]. More...
 
 ragged_array (const index_type xrow_ct, const index_type xvalue_ct)
 Creates an instance with xrow_ct rows and xvalue_ct values. More...
 
virtual ~ragged_array ()
 Destructor. More...
 
ragged_arrayoperator= (const ragged_array &xother)
 Assignment operator. More...
 
virtual bool operator== (const ragged_array &xother) const
 True if this is equivalent to xother. More...
 
index_type row_ct () const
 The number of rows. More...
 
index_type col_ct (const index_type xrow_index) const
 The number of columns for the xrow_index-th row. More...
 
index_typecol_cts () const
 The naked, underlying storage for number of columns for each row. More...
 
T * values () const
 The naked, underlying storage for the values in the array. More...
 
index_type value_ct () const
 The number of values. More...
 
T * row (const index_type xrow_index) const
 The row with index xrow_index. More...
 
T * operator[] (const index_type xrow_index) const
 The row index operator; alias for row(index_type). More...
 
void reset_rows ()
 Reinitializes access by row index using the column counts in col_cts(). More...
 
void reset_rows (const index_type *xcol_cts, const index_type xcol_cts_ub)
 Reinitializes access by row index using the column counts in xcol_cts. More...
 
index_type sum_col_cts () const
 The sum of the column counts in col_cts(). More...
 
index_type sum_col_cts (const index_type *xcol_cts, const index_type xcol_cts_ub) const
 The sum of the column counts in xcol_cts. More...
 
void initialize_push_back (index_type xrow_ct, index_type xvalue_ct)
 Reserves storage for xrow_ct rows containing xvalue_ct total values and initializes push_back into row 0 column 0. More...
 
index_type back_row () const
 The last row; the active row for push_back. More...
 
void new_back_row ()
 Creates a new last row. More...
 
void push_back (const T &xvalue)
 Add a value to the back of the back row. More...
 
void initialize (const index_type *xcol_cts, index_type xcol_cts_ub)
 Creates an instance with xcol_cts_ub rows, with the number of columns in the i-th row given by xcol_cts[i]. More...
 

ANY FACET

virtual ragged_arrayclone () const
 Virtual constructor; makes a new instance of the same type as this. More...
 
virtual bool invariant () const
 Class invariant. More...
 
virtual bool is_ancestor_of (const any *xother) const
 Conformance test; true if other conforms to this. More...
 

Additional Inherited Members

- Public Member Functions inherited from sheaf::rc_any
 rc_any ()
 Default constructor. More...
 
 rc_any (const rc_any &xother)
 Constructor. More...
 
rc_anyoperator= (const rc_any &xother)
 Assignment operator. More...
 
 ~rc_any ()
 Destructor. More...
 
void add_reference ()
 Increment the reference count. More...
 
void remove_reference ()
 Decrement the reference count. Delete this object if the reference count is zero. More...
 
bool is_shared () const
 True if the reference count is greater than one. More...
 
size_type ref_ct () const
 Return the reference count. More...
 
- Public Member Functions inherited from sheaf::any
bool is_same_type (const any *other) const
 True if other is the same type as this. More...
 
virtual ~any ()
 Destructor. More...
 
bool invariant_check () const
 True if invariant checking is enabled. More...
 
void enable_invariant_check () const
 Enable invariant checking. More...
 
void disable_invariant_check () const
 Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing invariant checking during multi-phase initialization. More...
 
int disable_invariance_check_request_depth () const
 Number of times disable_invariant_check has been called without matching call to enable_invariant_check. More...
 
- Protected Member Functions inherited from sheaf::any
 any ()
 default constructor More...
 
- Protected Attributes inherited from sheaf::rc_any
size_type _ref_ct
 Reference count. More...
 

Detailed Description

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

A two index array with variable length rows.

Definition at line 62 of file unstructured_block_builder.h.

Member Typedef Documentation

◆ index_type

template<typename T>
typedef unsigned long sheaf::ragged_array< T >::index_type

The integer type used to index this.

Definition at line 70 of file ragged_array.h.

◆ ptr

template<typename T>
typedef rc_ptr< ragged_array<T> > sheaf::ragged_array< T >::ptr

Reference counted pointer type.

Definition at line 76 of file ragged_array.h.

Constructor & Destructor Documentation

◆ ragged_array() [1/4]

template<typename T >
sheaf::ragged_array< T >::ragged_array ( size_t  xct = 0)

Default constructor; creates an empty array with one row and space reserved for xct values.

Postcondition
  • col_ct(0) == 0

Definition at line 46 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::ragged_array().

◆ ragged_array() [2/4]

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

Copy constructor.

Postcondition
  • (*this) == xother

Definition at line 78 of file ragged_array.impl.h.

◆ ragged_array() [3/4]

template<typename T >
sheaf::ragged_array< T >::ragged_array ( const index_type xcol_cts,
index_type  xcol_cts_ub 
)

Creates an instance with xrow_ct rows, with the number of columns in the i-th row given by xcol_cts[i].

Precondition
  • xcol_cts != 0
Postcondition
  • for(int i = ( 0 ); i < ( row_ct() ); ++ i ) col_ct(i) == xcol_cts[i]

Definition at line 96 of file ragged_array.impl.h.

◆ ragged_array() [4/4]

template<typename T >
sheaf::ragged_array< T >::ragged_array ( const index_type  xrow_ct,
const index_type  xvalue_ct 
)

Creates an instance with xrow_ct rows and xvalue_ct values.

Precondition
  • xrow_ct > 0
  • xvalue_ct > 0
Postcondition

Definition at line 120 of file ragged_array.impl.h.

◆ ~ragged_array()

template<typename T >
sheaf::ragged_array< T >::~ragged_array ( )
virtual

Destructor.

Definition at line 165 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::ragged_array().

Member Function Documentation

◆ back_row()

template<typename T >
ragged_array< T >::index_type sheaf::ragged_array< T >::back_row ( ) const

The last row; the active row for push_back.

Postcondition

Definition at line 535 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::initialize_push_back().

◆ clone()

template<typename T >
ragged_array< T > * sheaf::ragged_array< T >::clone ( ) const
virtual

Virtual constructor; makes a new instance of the same type as this.

Postcondition
  • for(int i = ( 0 ); i < ( row_ct() ); ++ i ) result->col_ct(i) == col_ct(i)

Reimplemented from sheaf::any.

Definition at line 667 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::initialize().

◆ col_ct()

◆ col_cts()

template<typename T >
ragged_array< T >::index_type * sheaf::ragged_array< T >::col_cts ( ) const

The naked, underlying storage for number of columns for each row.

Postcondition
  • result != 0
  • -unexecutable( result contains at least row_ct() entries )

Definition at line 281 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::col_ct().

◆ initialize()

template<typename T >
void sheaf::ragged_array< T >::initialize ( const index_type xcol_cts,
index_type  xcol_cts_ub 
)
protected

Creates an instance with xcol_cts_ub rows, with the number of columns in the i-th row given by xcol_cts[i].

Precondition
  • xcol_cts != 0
Postcondition
  • for(int i = ( 0 ); i < ( row_ct() ); ++ i ) col_ct(i) == xcol_cts[i]

Definition at line 611 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::push_back().

◆ initialize_push_back()

template<typename T >
void sheaf::ragged_array< T >::initialize_push_back ( index_type  xrow_ct,
index_type  xvalue_ct 
)

Reserves storage for xrow_ct rows containing xvalue_ct total values and initializes push_back into row 0 column 0.

Postcondition
  • col_ct(back_row()) == 0

Definition at line 496 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::sum_col_cts().

◆ invariant()

template<typename T >
bool sheaf::ragged_array< T >::invariant ( ) const
virtual

Class invariant.

Issue:
values() == 0 when using the default constructor.
Invariant

Reimplemented from sheaf::any.

Definition at line 692 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::clone().

◆ is_ancestor_of()

template<typename T >
bool sheaf::ragged_array< T >::is_ancestor_of ( const any xother) const
virtual

Conformance test; true if other conforms to this.

Precondition
  • xother != 0

Reimplemented from sheaf::any.

Definition at line 713 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::invariant().

◆ new_back_row()

template<typename T >
void sheaf::ragged_array< T >::new_back_row ( )

◆ operator=()

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

Assignment operator.

Postcondition
  • for(int i = ( 0 ); i < ( row_ct() ); ++ i ) col_ct(i) == xother.col_ct(i)

Definition at line 183 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::~ragged_array().

◆ operator==()

template<typename T >
bool sheaf::ragged_array< T >::operator== ( const ragged_array< T > &  xother) const
virtual

True if this is equivalent to xother.

Definition at line 211 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::operator=().

◆ operator[]()

template<typename T >
T * sheaf::ragged_array< T >::operator[] ( const index_type  xrow_index) const

The row index operator; alias for row(index_type).

Precondition
Postcondition
  • result != 0

Definition at line 372 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::row().

◆ push_back()

template<typename T>
void sheaf::ragged_array< T >::push_back ( const T &  xvalue)

Add a value to the back of the back row.

Postcondition
  • col_ct(back_row()) == old_col_ct + 1

Definition at line 582 of file ragged_array.impl.h.

Referenced by fiber_bundle::unary_index_space::neighbor_list(), fiber_bundle::binary_index_space::neighbor_list(), fiber_bundle::ternary_index_space::neighbor_list(), and sheaf::ragged_array< pod_index_type >::new_back_row().

◆ reset_rows() [1/2]

template<typename T >
void sheaf::ragged_array< T >::reset_rows ( )

Reinitializes access by row index using the column counts in col_cts().

Postcondition

Definition at line 396 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::operator[](), and sheaf::ragged_array< pod_index_type >::reset_rows().

◆ reset_rows() [2/2]

template<typename T >
void sheaf::ragged_array< T >::reset_rows ( const index_type xcol_cts,
const index_type  xcol_cts_ub 
)

Reinitializes access by row index using the column counts in xcol_cts.

Precondition
  • xcol_cts != 0
Postcondition
  • for(int i = ( 0 ); i < ( row_ct() ); ++ i ) col_ct(i) == xcol_cts[i]

Definition at line 426 of file ragged_array.impl.h.

◆ row()

template<typename T >
T * sheaf::ragged_array< T >::row ( const index_type  xrow_index) const

The row with index xrow_index.

Precondition
Postcondition
  • result != 0

Definition at line 348 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array_index_space_interval::contains_unglued_hub(), sheaf::ragged_array_index_space_interval::pod(), and sheaf::ragged_array< pod_index_type >::value_ct().

◆ row_ct()

◆ sum_col_cts() [1/2]

template<typename T >
ragged_array< T >::index_type sheaf::ragged_array< T >::sum_col_cts ( ) const

◆ sum_col_cts() [2/2]

template<typename T >
ragged_array< T >::index_type sheaf::ragged_array< T >::sum_col_cts ( const index_type xcol_cts,
const index_type  xcol_cts_ub 
) const

The sum of the column counts in xcol_cts.

Precondition
  • xcol_cts != 0

Definition at line 471 of file ragged_array.impl.h.

◆ value_ct()

template<typename T >
ragged_array< T >::index_type sheaf::ragged_array< T >::value_ct ( ) const

The number of values.

Definition at line 328 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::values().

◆ values()

template<typename T >
T * sheaf::ragged_array< T >::values ( ) const

The naked, underlying storage for the values in the array.

Postcondition
  • -unexecutable( result contains value_ct() entries )

Definition at line 304 of file ragged_array.impl.h.

Referenced by sheaf::ragged_array< pod_index_type >::clone(), sheaf::ragged_array< pod_index_type >::col_cts(), and sheaf::ragged_array< pod_index_type >::operator=().

Friends And Related Function Documentation

◆ deep_size

template<typename T>
size_t deep_size ( const ragged_array< T > &  xra,
bool  xinclude_shallow = true 
)
friend

The deep size of the referenced object of type ragged_array<T>; if xinclude_shallow, add the sizeof xp to the result.

Postcondition
  • result >= 0

Definition at line 759 of file ragged_array.impl.h.

Member Data Documentation

◆ _col_cts

template<typename T>
block<index_type> sheaf::ragged_array< T >::_col_cts
protected

The number of columns in each row.

Definition at line 211 of file ragged_array.h.

Referenced by sheaf::deep_size(), and sheaf::ragged_array< pod_index_type >::operator=().

◆ _row_ptrs

template<typename T>
block<index_type> sheaf::ragged_array< T >::_row_ptrs
protected

Index of the first value in each row.

Definition at line 216 of file ragged_array.h.

Referenced by sheaf::deep_size().

◆ _values

template<typename T>
block<T> sheaf::ragged_array< T >::_values
protected

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