21 #include "SheafSystem/list_index_space_state.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/list_index_space_handle.h" 24 #include "SheafSystem/list_index_space_iterator.h" 25 #include "SheafSystem/deep_size.h" 26 #include "SheafSystem/index_space_family.h" 27 #include "SheafSystem/hub_index_space_handle.h" 38 const std::string& xname,
43 require(!xname.empty());
44 require(!xid_spaces.
contains(xname));
49 lstate->new_state(xid_spaces, xname, xis_persistent);
55 ensure(&result.
id_spaces() == &xid_spaces);
60 ensure(result.
name() == xname);
73 const std::string& xname,
80 require(!xname.empty());
81 require(!xid_spaces.
contains(xname));
86 lstate->new_state(xid_spaces, xid, xname, xis_persistent);
92 ensure(&result.
id_spaces() == &xid_spaces);
96 ensure(result.
index() == xid);
98 ensure(result.
name() == xname);
196 ensure(
ct() == old_ct + 1);
197 ensure(
begin() == 0);
198 ensure(
ct() > 1 ?
end() == old_end+1 :
end() == 1);
219 define_old_variable(
pod_type old_domain_id =
pod(xold_range_id));
221 to_range_type::iterator litr =
to_range_itr(xold_range_id,
true);
224 *litr = xnew_range_id;
232 ensure(old_contains_xold_range_id ?
pod(xnew_range_id) == old_domain_id :
true);
353 ensure(is_basic_query);
406 ensure(
contains(old_next_id, xrange_id));
424 define_old_variable(
pod_type old_itr_pod = xitr.
pod());
447 ensure(
contains(old_itr_pod, xrange_id));
448 ensure(xitr.
pod() == old_itr_pod+1);
449 ensure(xitr.
hub_pod() == old_itr_hub_pod);
463 define_old_variable(
bool old_contains_entry = xis_range_id ?
contains_hub(xid) :
contains(xid));
464 define_old_variable(
pod_type old_pod = xis_range_id ?
pod(xid) : xid);
465 define_old_variable(
pod_type old_hub_pod = xis_range_id ? xid :
hub_pod(xid));
473 to_range_type::iterator litr =
to_range_itr(xid, xis_range_id);
550 ensure(!old_contains_entry || !
contains(old_pod, old_hub_pod));
551 ensure((result == 0) || (result == 1));
570 define_old_variable(
pod_type old_itr_id = xitr.
pod());
587 litr.invalidate_ids();
593 litr._hub_pod = *litr._itr;
599 ensure(xitr.
is_done() || xitr.
pod() == old_itr_id);
600 ensure(unexecutable(
"xitr.is_done() || xitr.hub_pod() == old_next_itr_hub_pod"));
622 ensure(unexecutable(
"map rep is empty"));
665 ensure(unexecutable(
"map rep is gathered"));
672 sheaf::list_index_space_state::to_range_type::iterator
683 to_range_type::iterator result;
698 for(result =
_to_range.begin(), ldomain_id = 0; result !=
_to_range.end(); ++result, ++ldomain_id)
700 if(ldomain_id == xid)
716 sheaf::list_index_space_state::to_range_type::const_iterator
727 to_range_type::const_iterator result;
742 for(result =
_to_range.begin(), ldomain_id = 0; result !=
_to_range.end(); ++result, ++ldomain_id)
744 if(ldomain_id == xid)
831 (void) gathered_insertion_index_space_state::operator=(xother);
836 ensure((*
this) == xother);
866 bool result = (
_begin <= xid) && (xid <
_end);
886 ensure(is_basic_query);
919 ensure(is_basic_query);
935 bool result = (litr !=
_to_range.end()) && (*litr == xhub_id);
954 ensure(is_basic_query);
972 to_range_type::const_iterator itr;
974 for(itr =
_to_range.begin(), ldomain_id = 0; itr !=
_to_range.end(); ++itr, ++ldomain_id)
1049 ensure(result >= 0);
1068 ensure(result >= 0);
1111 handles().release(reinterpret_cast<list_index_space_handle&>(xid_space));
1115 ensure(is_basic_query);
1133 bool result = (lid_space != 0) && handles().allocated(*lid_space);
1137 ensure(is_basic_query);
1149 sheaf::list_index_space_state::
1160 ensure(is_basic_query);
1186 ensure(result >= 0);
1205 ensure(result >= 0);
1248 iterators().release(reinterpret_cast<list_index_space_iterator&>(xitr));
1252 ensure(is_basic_query);
1270 bool result = (litr != 0) && iterators().allocated(*litr);
1274 ensure(is_basic_query);
1286 sheaf::list_index_space_state::
1297 ensure(is_basic_query);
1315 static const std::string result(
"list_index_space_state");
1331 ensure(result != 0);
1344 sheaf::list_index_space_state::
1375 require(other != 0);
1438 size_t result = xinclude_shallow ?
sizeof(xn) : 0;
1451 ensure(result >= 0);
bool contains_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space. synonym for contains...
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
std::list< pod_type > to_range_type
The type of the domain id to range id map.
size_type ct() const
The number of members.
virtual pod_type index() const
Index of this space.
virtual const std::string & class_name() const
The name of this class.
An abstract iterator over the ids of an id space.
virtual list_index_space_state * clone() const
Virtual constructor; create a new instance of the same type at this.
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
virtual ~list_index_space_state()
Destructor.
pod_type end() const
Ending id of this space.
virtual index_space_handle & get_id_space() const
The id space handle with this state.
pod_type pod() const
The current id in the iteration.
An list implementation of class gathered_insertion_index_space_state. This representation is intended...
virtual pod_type unglued_hub_pod(pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in this id space.
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
virtual bool is_persistent() const
True if this id space should be written to disk.
list_index_space_state()
Default constructor.
static list_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent)
Create a new list id space in the id space family xid_space at the next available id space index with...
static size_type iterator_pool_deep_size()
The deep size of the iterator pool.
virtual void map_rep_push(index_space_iterator &xitr, pod_type xrange_id)
Inserts entry (xitr.pod(), xrange_id) into the map representation. Increments all domain ids greater ...
An map implementation of class scattered_insertion_index_space_handle. This representation is intende...
to_range_type & to_range()
The representation of the domain id to range id map. Warning: direct manipulation of the to_range map...
to_range_type _to_range
The representation of the domain id to range id map.
virtual void detach()=0
Detach this handle form its state, if any.
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
virtual const index_space_family & id_spaces() const
The id space family for this (const version).
virtual bool allocated_iterator(const index_space_iterator &xitr) const
True if and only if id space iterator xitr was allocated by the iterator pool.
virtual void detach()=0
Detach this handle form its state, if any.
pod_type back() const
The back of the list used to represent this id space; equivalent to hub_pod(last id).
void attach(explicit_index_space_handle &xid_space) const
Attach the id space handle xid_space to this state.
static size_type iterator_pool_ct()
The number of iterators in the pool.
pod_type _end
Ending id of this space.
pod_type _capacity
The capacity of this map.
Abstract base class with useful features for all objects.
virtual list_index_space_state & operator=(const explicit_index_space_state &xother)
Assignment operator.
to_range_type::const_iterator to_range_const_itr(pod_type xid, bool xis_range_id) const
A const_iterator pointing to the _to_range entry with range id (xis_range_id true) or domain id (xis_...
virtual bool invariant() const
Class invariant.
pod_type front() const
The front of the list used to represent this id space; equivalent to hub_pod(begin()).
bool is_done() const
True if iteration is finished.
virtual void reserve(size_type xcapacity)
Reserve enough memory for xcapacity number of ids.
An immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
virtual void release_id_space(index_space_handle &xid_space) const
Release the id space handle xid_space.
virtual void map_rep_gather()
Gathers the map representation into an interval.
std::string name() const
Name of this space.
An iterator over an id space in which the equivalence between the ids in the space and the hub id spa...
pod_type begin() const
Beginning id of this space.
friend SHEAF_DLL_SPEC size_t deep_size(const list_index_space_state &xn, bool xinclude_shallow)
The deep size of list_index_space_state& xn.
virtual bool is_attached() const
True if this handle is attached to a state.
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
virtual bool conforms_to_state(const index_space_collection &xhost, pod_type xlocal_id) const
True if this conforms to the handle type required by the state with local scope id xlocal_id in the h...
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
virtual bool invariant() const
Class invariant.
bool is_explicit_interval(pod_type xid)
True, if and only if the id space interval that contains index xid is an explicit interval...
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual size_type map_rep_remove_entry(pod_type xid, bool xis_range_id)
Removes the entry containing range id xid (xis_range_id true) or domain id xid (xis_range_id false) f...
void push_front(pod_type xhub_id)
Pushes hub id xhub_id onto the front of the list used to represent this id space; increments the doma...
to_range_type::iterator to_range_itr(pod_type xid, bool xis_range_id)
An iterator pointing to the _to_range entry with range id (xis_range_id true) or domain id (xis_range...
virtual bool contains_unglued_hub(pod_type xid) const
True if this space contains an id equivalent to xid in the unglued hub id space.
virtual void map_rep_push_back(pod_type xrange_id)
Inserts entry (next_id(), xrange_id) into the map representation.
size_type capacity() const
The number of ids reserved in memory.
static size_type handle_pool_deep_size()
The deep size of the handle pool.
virtual bool allocated_id_space(const index_space_handle &xid_space) const
True if and only if id space handle xid_space was allocated by the handle pool.
virtual bool contains(pod_type xid) const
True if this space contains id xid.
size_type _ct
The number of members.
bool invariant_check() const
True if invariant checking is enabled.
pod_index_type pod_type
The "plain old data" index type for this.
int_type pod_index_type
The plain old data index type.
virtual size_type capacity() const
The number of ids reserved in memory.
void replace_range_id(pod_type xold_range_id, pod_type xnew_range_id)
Replaces xold_range_id with xnew_range_id.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
bool is_empty() const
True if there are no ids in the space.
Factory and container for a family of id spaces.
An implementation of class explicit_index_space_state that supports gathered insertion of new members...
void reverse(bool xupdate_extrema)
Reverse the order, for instance hub_pod(new 0) = hub_pod(old last);.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
static factory< explicit_index_space_state > & id_space_factory()
A factory for making descendants of this class.
pod_type _begin
Beginning id of this space.
SHEAF_DLL_SPEC pod_index_type invalid_pod_index()
The invalid pod index value.
pod_type next_id() const
The id inserted by the next call to push_back.
bool is_same_type(const any *other) const
True if other is the same type as this.
static size_type handle_pool_ct()
The number of handles in the pool.
void enable_invariant_check() const
Enable invariant checking.
to_hub_type::iterator _itr
The stl iterator over ids.
virtual bool is_attached() const
True if this iterator is attached to a state.
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
pod_type hub_pod(pod_type xid) const
The pod index in the unglued hub id space equivalent to xid in this id space. synonym for unglued_hub...
A reallocated pool of objects of type T. Objects in the pool are either allocated or stored in a free...
virtual void map_rep_clear()
Removes all entrires from the map representation.
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
virtual void update_extrema()
Update the id extrema.