1 #ifndef BIT_VECTOR_CLASS
2 #define BIT_VECTOR_CLASS
49 bool on(
int position)
const;
52 bool off(
int position)
const;
55 void set_bit(
int position,
bool value);
69 void light(
int position);
72 void clear(
int position);
129 struct two_dim_location {
int c_byte;
int c_offset; };
132 two_dim_location into_two_dim(
int position)
const;
135 bool get_bit(
const two_dim_location &pos_in2)
const;
137 void set_bit(
const two_dim_location &pos_in2,
bool value);
146 template <
class type>
147 void SET(type &to_modify, type bits) { to_modify |= bits; }
150 template <
class type>
151 void CLEAR(type &to_modify, type bits) { to_modify &= (type)~bits; }
154 template <
class type>
155 bool TEST(type to_test, type bits) {
return bool(!(!(to_test & bits))); }
Provides a dynamically resizable ASCII character string.
A very common template for a dynamic array of bytes.
An array of bits with operations for manipulating and querying individual bits.
void clear(int position)
clears the value of the bit at "position".
bool set(int start, int size, basis::un_int source)
puts the "source" value into the vector at "start".
bool whole() const
returns true if entire vector is set.
bool on(int position) const
returns true if the bit at "position" is set.
int find_first(bool to_find) const
Seeks the first occurrence of "to_find".
basis::astring text_form() const
prints a nicely formatted list of bits to a string.
bool empty() const
returns true if entire vector is unset.
int bits() const
returns the number of bits in the vector.
bool operator==(const bit_vector &that) const
returns true if "this" is equal to "that".
void light(int position)
sets the value of the bit at "position".
basis::un_int get(int start, int size) const
gets a portion of the vector as an unsigned integer.
void reset(int size)
resizes the bit_vector and clears all bits in it.
bool compare(const bit_vector &that, int start, int stop) const
true if "this" is the same as "that" between "start" and "stop".
void set_bit(int position, bool value)
sets the bit at "position" to a particular "value".
bit_vector()
creates a zero length bit_vector.
bool off(int position) const
returns true if the bit at "position" is clear.
bit_vector & operator=(const bit_vector &to_copy)
bool operator[](int position) const
returns the value of the bit at the position specified.
bool overwrite(int start, const bit_vector &to_write)
Stores bits from "to_write" into "this" at "start".
bit_vector subvector(int start, int end) const
Extracts a chunk of the vector between "start" and "end".
void resize(int size)
Changes the size of the bit_vector to "size" bits.
Constants and objects used throughout HOOPLE.
#define NULL_POINTER
The value representing a pointer to nothing.
unsigned char abyte
A fairly important unit which is seldom defined...
unsigned int un_int
Abbreviated name for unsigned integers.
A dynamic container class that holds any kind of object via pointers.
bool TEST(type to_test, type bits)
returns non-zero if the "bits" bit pattern is turned on in "to_test".
void SET(type &to_modify, type bits)
returns a number based on "to_modify" but with "bits" turned on.
void CLEAR(type &to_modify, type bits)
returns a number based on "to_modify" but with "bits" turned off.