22 #ifndef LIBSEMIGROUPS_SRC_BLOCKS_H_ 23 #define LIBSEMIGROUPS_SRC_BLOCKS_H_ 29 #include "libsemigroups-debug.h" 50 Blocks() : _blocks(nullptr), _lookup(nullptr), _nr_blocks(0), _rank(0) {}
66 : _blocks(blocks), _lookup(
lookup), _nr_blocks(), _rank(UNDEFINED) {
67 LIBSEMIGROUPS_ASSERT(_blocks->size() != 0);
68 _nr_blocks = *(std::max_element(_blocks->begin(), _blocks->end())) + 1;
69 LIBSEMIGROUPS_ASSERT(_nr_blocks == _lookup->size());
92 Blocks(std::vector<u_int32_t>* blocks,
99 LIBSEMIGROUPS_ASSERT(_blocks->size() != 0);
100 LIBSEMIGROUPS_ASSERT(_nr_blocks == _lookup->size());
139 return (_nr_blocks == 0 ? 0 : _blocks->size());
146 inline u_int32_t
block(
size_t pos)
const {
147 LIBSEMIGROUPS_ASSERT(pos < _blocks->size());
148 return (*_blocks)[pos];
158 LIBSEMIGROUPS_ASSERT(index < _nr_blocks);
159 return (*_lookup)[index];
168 inline std::vector<bool>
const*
lookup()
const {
195 inline typename std::vector<u_int32_t>::const_iterator
cbegin()
const {
196 LIBSEMIGROUPS_ASSERT(_blocks !=
nullptr);
197 return _blocks->cbegin();
203 inline typename std::vector<u_int32_t>::const_iterator
cend()
const {
204 LIBSEMIGROUPS_ASSERT(_blocks !=
nullptr);
205 return _blocks->cend();
209 std::vector<u_int32_t>* _blocks;
210 std::vector<bool>* _lookup;
211 u_int32_t _nr_blocks;
213 static u_int32_t
const UNDEFINED = std::numeric_limits<u_int32_t>::max();
217 #endif // LIBSEMIGROUPS_SRC_BLOCKS_H_ Blocks()
A constructor.
Definition: blocks.h:50
~Blocks()
Default destructor.
Definition: blocks.h:116
std::vector< u_int32_t >::const_iterator cbegin() const
Returns a const_iterator pointing to the index of the first block.
Definition: blocks.h:195
Class for signed partitions of the set .
Definition: blocks.h:45
Blocks(std::vector< u_int32_t > *blocks, std::vector< bool > *lookup, u_int32_t nr_blocks)
A constructor.
Definition: blocks.h:92
bool operator==(const Blocks &that) const
Returns true if this equals that.
Definition: blocks.cc:48
bool is_transverse_block(size_t index) const
Returns true if the block with index index is transverse.
Definition: blocks.h:157
size_t hash_value() const
Returns a hash value for a this.
Definition: blocks.cc:85
u_int32_t nr_blocks() const
Returns the number of blocks in the Blocks object.
Definition: blocks.h:176
Namespace for everything in the libsemigroups library.
Definition: blocks.cc:32
Blocks & operator=(Blocks const ©)=delete
The assignment operator is deleted for Blocks to avoid unintended copying.
u_int32_t rank()
Returns the number of signed (transverse) blocks in this.
Definition: blocks.cc:78
u_int32_t block(size_t pos) const
Returns the index of the block containing pos.
Definition: blocks.h:146
Blocks(std::vector< u_int32_t > *blocks, std::vector< bool > *lookup)
A constructor.
Definition: blocks.h:65
std::vector< bool > const * lookup() const
Returns a pointer to the lookup table for block indices.
Definition: blocks.h:168
std::vector< u_int32_t >::const_iterator cend() const
Returns a const_iterator referring to past-the-end of the last block.
Definition: blocks.h:203
u_int32_t degree() const
Returns the degree of a Blocks object.
Definition: blocks.h:138
bool operator<(const Blocks &that) const
Returns true if this is less than that.
Definition: blocks.cc:59