21 #include "SheafSystem/hash_index_space_state.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/hash_index_space_handle.h" 24 #include "SheafSystem/hash_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" 41 const std::string& xname,
47 require(!xname.empty());
48 require(!xid_spaces.
contains(xname));
49 require(xcapacity >= 0);
54 lstate->
new_state(xid_spaces, xname, xis_persistent);
62 ensure(&result.
id_spaces() == &xid_spaces);
67 ensure(result.
name() == xname);
69 ensure(result.
capacity() >= xcapacity);
80 const std::string& xname,
88 require(!xname.empty());
89 require(!xid_spaces.
contains(xname));
90 require(xcapacity >= 0);
95 lstate->
new_state(xid_spaces, xid, xname, xis_persistent);
103 ensure(&result.
id_spaces() == &xid_spaces);
107 ensure(result.
index() == xid);
109 ensure(result.
name() == xname);
111 ensure(result.
capacity() >= xcapacity);
188 for(to_range_type::const_iterator itr =
_to_range.begin();
212 size_type lbucket_ct = (xcapacity / 2) + (xcapacity % 2);
240 ensure(is_basic_query);
280 ensure(
contains(xdomain_id, xrange_id));
306 ensure(
contains(old_next_id, xrange_id));
324 define_old_variable(
pod_type old_itr_pod = xitr.
pod());
335 ensure(
contains(old_itr_pod, xrange_id));
336 ensure(xitr.
pod() == old_itr_pod+1);
337 ensure(xitr.
hub_pod() == old_itr_hub_pod);
358 to_domain_type::iterator itr =
_to_domain.find(xid);
378 to_range_type::iterator itr =
_to_range.find(xid);
418 define_old_variable(
pod_type old_itr_id = xitr.
pod());
429 ensure(xitr.
is_done() || xitr.
pod() > old_itr_id);
452 ensure(unexecutable(
"map rep is empty"));
475 to_range_type::iterator lto_range_itr =
_to_range.begin();
478 lrange_id = lto_range_itr->second;
505 to_domain_type::iterator lto_domain_itr =
_to_domain.begin();
510 _to_range[lto_domain_itr->second] = lto_domain_itr->first;
519 ensure(unexecutable(
"map rep is gathered"));
598 (void) scattered_insertion_index_space_state::operator=(xother);
603 ensure((*
this) == xother);
631 ensure(is_basic_query);
650 ensure(is_basic_query);
665 to_range_type::const_iterator itr =
_to_range.find(xid);
667 bool result = (itr !=
_to_range.end()) && (itr->second == xhub_id);
671 ensure(is_basic_query);
686 to_domain_type::const_iterator itr =
_to_domain.find(xhub_id);
708 to_range_type::const_iterator itr =
_to_range.find(xid);
807 handles().release(reinterpret_cast<hash_index_space_handle&>(xid_space));
811 ensure(is_basic_query);
829 bool result = (lid_space != 0) && handles().allocated(*lid_space);
833 ensure(is_basic_query);
845 sheaf::hash_index_space_state::
856 ensure(is_basic_query);
944 iterators().release(reinterpret_cast<hash_index_space_iterator&>(xitr));
948 ensure(is_basic_query);
966 bool result = (litr != 0) && iterators().allocated(*litr);
970 ensure(is_basic_query);
982 sheaf::hash_index_space_state::
993 ensure(is_basic_query);
1011 static const std::string result(
"hash_index_space_state");
1027 ensure(result != 0);
1040 sheaf::hash_index_space_state::
1071 require(other != 0);
1131 size_t result = xinclude_shallow ?
sizeof(xn) : 0;
1142 result += deep_size<pod_type, pod_type, to_domain_policy_type>(xn.
_to_domain,
false);
1147 result += deep_size<pod_type, pod_type, to_range_policy_type>(xn.
_to_range,
false);
1151 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 bool invariant() const
Class invariant.
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...
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
virtual pod_type index() const
Index of this space.
virtual index_space_iterator & get_iterator() const
Allocates an id space iterator from the iterator pool.
An abstract iterator over the ids of an id space.
virtual void map_rep_gather()
Gathers the map representation into an interval.
pod_type pod() const
The current id in the iteration.
virtual pod_type pod(pod_type xid) const
The pod index in this space equivalent to xid in the hub id space.
An hash map implementation of class scattered_insertion_index_space_handle. This representation is in...
virtual bool is_persistent() const
True if this id space should be written to disk.
virtual void map_rep_push_back(pod_type xrange_id)
Inserts entry (next_id(), xrange_id) into the map representation.
virtual void detach()=0
Detach this handle form its state, if any.
An implementation of class explicit_index_space_state that supports either gathered or scattered inse...
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 void detach()=0
Detach this handle form its state, if any.
static size_type iterator_pool_deep_size()
The deep size of the iterator pool.
void attach(explicit_index_space_handle &xid_space) const
Attach the id space handle xid_space to this state.
pod_type _end
Ending id of this space.
static size_type handle_pool_deep_size()
The deep size of the handle pool.
virtual void map_rep_insert_entry(pod_type xdomain_id, pod_type xrange_id)
Inserts entry (xdomain_id, xrange_id) into the map representation.
virtual bool invariant() const
Class invariant.
Abstract base class with useful features for all objects.
bool is_done() const
True if iteration is finished.
static size_type iterator_pool_ct()
The number of iterators in the 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 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 immutable abstract state for a space of alternate integer identifiers (aliases) for a subset of th...
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.
std::string name() const
Name of this space.
Do not call deep_size on either the key or value.
virtual bool is_attached() const
True if this handle is attached to a state.
SHEAF_DLL_SPEC pod_index_type max_pod_index()
The maximum pod index value.
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.
virtual void release_iterator(index_space_iterator &xitr) const
Returns the id space iterator xitr to the iterator pool.
hash_index_space_state()
Default constructor.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
const hub_index_space_handle & hub_id_space() const
The hub id space.
static size_type handle_pool_ct()
The number of handles in the pool.
bool is_explicit_interval(pod_type xid)
True, if and only if the id space interval that contains index xid is an explicit interval...
virtual void reserve(size_type xcapacity)
Reserve enough memory for xcapacity number of ids.
to_domain_type _to_domain
The representation of the range id to domain id map.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
void new_state(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent)
Create a new id space state in the id space family xid_spaces at the next available id space index wi...
virtual bool contains(pod_type xid) const
True if this space contains id xid.
virtual void update_extrema()
Update the id extrema.
virtual index_space_handle & get_id_space() const
The id space handle with this state.
virtual hash_index_space_state & operator=(const explicit_index_space_state &xother)
Assignment operator.
An hash map implementation of class scattered_insertion_index_space_state. This representation is int...
SHEAF_DLL_SPEC pod_index_type min_pod_index()
The minimum pod index value.
virtual bool operator==(const explicit_index_space_state &xother) const
True if this is equivalent to xother.
size_type capacity() const
The number of ids reserved in memory.
size_type _ct
The number of members.
virtual const std::string & class_name() const
The name of this class.
virtual hash_index_space_state * clone() const
Virtual constructor; create a new instance of the same type at this.
bool invariant_check() const
True if invariant checking is enabled.
to_range_type _to_range
The representation of the domain id to range id map.
pod_index_type pod_type
The "plain old data" index type for this.
virtual size_type capacity() const
The number of ids reserved in memory.
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.
int_type pod_index_type
The plain old data index type.
virtual pod_type unglued_hub_pod(pod_type xid) const
The pod index in the hub id space equivalent to xid in this id space.
bool contains(pod_type xid) const
True, if this contains an id space with id xid.
virtual void map_rep_clear()
Removes all entrires from the map representation.
An iterator over an id space in which the equivalence between the ids in the space and the hub id spa...
bool is_empty() const
True if there are no ids in the space.
Factory and container for a family of id spaces.
virtual ~hash_index_space_state()
Destructor.
virtual void release_id_space(index_space_handle &xid_space) const
Release the id space handle xid_space.
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.
void enable_invariant_check() const
Enable invariant checking.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
virtual bool is_attached() const
True if this iterator is attached to a state.
A reallocated pool of objects of type T. Objects in the pool are either allocated or stored in a free...
virtual bool contains(pod_type xid) const
True if this space contains id xid.
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...
static hash_index_space_handle new_space(index_space_family &xid_spaces, const std::string &xname, bool xis_persistent, size_type xcapacity)
Create a new hash id space in the id space family xid_space at the next available id space index with...
pod_type hub_pod() const
The current unglued hub id in the iteration. synonym for unglued_hub_pod().
friend SHEAF_DLL_SPEC size_t deep_size(const hash_index_space_state &xn, bool xinclude_shallow)
The deep size of hash_index_space_state& xn.