mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
putil: Improve SparseArray output printing
This commit is contained in:
parent
0c5fedfc9b
commit
77f486a07b
@ -215,21 +215,28 @@ has_bits_in_common(const SparseArray &other) const {
|
|||||||
*/
|
*/
|
||||||
void SparseArray::
|
void SparseArray::
|
||||||
output(std::ostream &out) const {
|
output(std::ostream &out) const {
|
||||||
|
if (_subranges.empty()) {
|
||||||
|
out << (_inverse ? "[ all ]" : "[ ]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
out << "[ ";
|
out << "[ ";
|
||||||
if (_inverse) {
|
if (_inverse) {
|
||||||
out << "all except: ";
|
out << "all except: ";
|
||||||
}
|
}
|
||||||
Subranges::const_iterator si;
|
Subranges::const_iterator si;
|
||||||
for (si = _subranges.begin(); si != _subranges.end(); ++si) {
|
for (si = _subranges.begin(); si != _subranges.end(); ++si) {
|
||||||
|
if (si != _subranges.begin()) {
|
||||||
|
out << ", ";
|
||||||
|
}
|
||||||
if ((*si)._end == (*si)._begin + 1) {
|
if ((*si)._end == (*si)._begin + 1) {
|
||||||
// A single element.
|
// A single element.
|
||||||
out << (*si)._begin << ", ";
|
out << (*si)._begin;
|
||||||
} else {
|
} else {
|
||||||
// A range of elements.
|
// A range of elements.
|
||||||
out << (*si)._begin << "-" << ((*si)._end - 1) << ", ";
|
out << (*si)._begin << "-" << ((*si)._end - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out << "]";
|
out << " ]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user