43class EXPCL_PANDA_PUTIL SparseArray {
48 INLINE
static SparseArray
all_on();
49 INLINE
static SparseArray
all_off();
50 INLINE
static SparseArray
lower_on(
int on_bits);
51 INLINE
static SparseArray
bit(
int index);
52 INLINE
static SparseArray
range(
int low_bit,
int size);
58 INLINE
bool get_bit(
int index)
const;
66 INLINE
bool has_any_of(
int low_bit,
int size)
const;
67 INLINE
bool has_all_of(
int low_bit,
int size)
const;
68 INLINE
void set_range(
int low_bit,
int size);
70 INLINE
void set_range_to(
bool value,
int low_bit,
int size);
84 void output(std::ostream &out)
const;
86 INLINE
bool operator == (
const SparseArray &other)
const;
87 INLINE
bool operator != (
const SparseArray &other)
const;
88 INLINE
bool operator < (
const SparseArray &other)
const;
89 int compare_to(
const SparseArray &other)
const;
92 operator & (
const SparseArray &other)
const;
95 operator | (
const SparseArray &other)
const;
98 operator ^ (
const SparseArray &other)
const;
104 operator << (
int shift)
const;
107 operator >> (
int shift)
const;
109 void operator &= (
const SparseArray &other);
110 void operator |= (
const SparseArray &other);
111 void operator ^= (
const SparseArray &other);
112 INLINE
void operator <<= (
int shift);
113 INLINE
void operator >>= (
int shift);
120 EXTENSION(PyObject *__getstate__()
const);
121 EXTENSION(
void __setstate__(PyObject *state));
124 void do_add_range(
int begin,
int end);
125 void do_remove_range(
int begin,
int end);
126 bool do_has_any(
int begin,
int end)
const;
127 bool do_has_all(
int begin,
int end)
const;
129 void do_intersection(
const SparseArray &other);
130 void do_union(
const SparseArray &other);
131 void do_intersection_neg(
const SparseArray &other);
132 void do_shift(
int offset);
137 INLINE Subrange(
int begin,
int end);
138 INLINE
bool operator < (
const Subrange &other)
const;
144 Subranges _subranges;
157 static void init_type() {
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
A dynamic array with an unlimited number of bits.
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
The default class template does not define any methods.
This class records a set of integers, where each integer is either present or not present in the set.
int get_num_off_bits() const
Returns the number of bits that are set to 0 in the array.
void write_datagram(BamWriter *manager, Datagram &dg) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
void read_datagram(DatagramIterator &scan, BamReader *manager)
Reads the object that was previously written to a Bam file.
void invert_in_place()
Inverts all the bits in the SparseArray.
static SparseArray lower_on(int on_bits)
Returns a SparseArray whose lower on_bits bits are on.
bool has_any_of(int low_bit, int size) const
Returns true if any bit in the indicated range is set, false otherwise.
bool get_bit(int index) const
Returns true if the nth bit is set, false if it is cleared.
void clear_range(int low_bit, int size)
Sets the indicated range of bits off.
void clear()
Sets all the bits in the SparseArray off.
int get_subrange_begin(size_t n) const
Returns the first numeric element in the nth subrange.
bool has_all_of(int low_bit, int size) const
Returns true if all bits in the indicated range are set, false otherwise.
int get_lowest_off_bit() const
Returns the index of the lowest 0 bit in the array.
bool has_bits_in_common(const SparseArray &other) const
Returns true if this SparseArray has any "one" bits in common with the other one, false otherwise.
int compare_to(const SparseArray &other) const
Returns a number less than zero if this SparseArray sorts before the indicated other SparseArray,...
static bool has_max_num_bits()
Returns true if there is a maximum number of bits that may be stored in this structure,...
void set_bit_to(int index, bool value)
Sets the nth bit either on or off, according to the indicated bool value.
void set_range(int low_bit, int size)
Sets the indicated range of bits on.
static SparseArray range(int low_bit, int size)
Returns a SparseArray whose size bits, beginning at low_bit, are on.
static int get_max_num_bits()
If get_max_num_bits() returned true, this method may be called to return the maximum number of bits t...
size_t get_num_subranges() const
Returns the number of separate subranges stored in the SparseArray.
bool get_highest_bits() const
Returns true if the infinite set of bits beyond get_num_bits() are all on, or false of they are all o...
static SparseArray bit(int index)
Returns a SparseArray with only the indicated bit on.
int get_highest_off_bit() const
Returns the index of the highest 0 bit in the array.
int get_subrange_end(size_t n) const
Returns the last numeric element, plus one, in the nth subrange.
bool is_zero() const
Returns true if the entire bitmask is zero, false otherwise.
bool is_inverse() const
If this is true, the SparseArray is actually defined as a list of subranges of integers that are *not...
int get_num_on_bits() const
Returns the number of bits that are set to 1 in the array.
bool is_all_on() const
Returns true if the entire bitmask is one, false otherwise.
void set_bit(int index)
Sets the nth bit on.
static SparseArray all_off()
Returns a SparseArray whose bits are all off.
void clear_bit(int index)
Sets the nth bit off.
void set_range_to(bool value, int low_bit, int size)
Sets the indicated range of bits to either on or off.
int get_num_bits() const
Returns the current number of possibly different bits in this array.
static SparseArray all_on()
Returns a SparseArray with an infinite array of bits, all on.
int get_next_higher_different_bit(int low_bit) const
Returns the index of the next bit in the array, above low_bit, whose value is different that the valu...
TypeHandle is the identifier used to differentiate C++ class types.
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_highest_on_bit(unsigned short x)
Returns the index of the highest 1 bit in the word.
int get_lowest_on_bit(unsigned short x)
Returns the index of the lowest 1 bit in the word.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.