21 InternalNameCollection::
22 InternalNameCollection() {
28 InternalNameCollection::
37 void InternalNameCollection::
51 if (_names.get_ref_count() > 1) {
52 InternalNames old_names = _names;
53 _names = InternalNames::empty_array(0);
54 _names.v() = old_names.v();
57 _names.push_back(name);
67 for (
int i = 0; name_index == -1 && i < (int)_names.size(); i++) {
68 if (_names[i] == name) {
73 if (name_index == -1) {
82 if (_names.get_ref_count() > 1) {
83 InternalNames old_names = _names;
84 _names = InternalNames::empty_array(0);
85 _names.v() = old_names.v();
88 _names.erase(_names.begin() + name_index);
100 for (
int i = 0; i < other_num_names; i++) {
112 InternalNames new_names;
114 for (
int i = 0; i < num_names; i++) {
117 new_names.push_back(name);
130 InternalNames new_names;
133 for (
int i = 0; i < num_names; i++) {
135 bool duplicated =
false;
137 for (
int j = 0; j < i && !duplicated; j++) {
142 new_names.push_back(name);
174 int InternalNameCollection::
175 get_num_names()
const {
176 return _names.size();
184 nassertr(index >= 0 && index < (
int)_names.size(),
nullptr);
186 return _names[index];
195 nassertr(index >= 0 && index < (
int)_names.size(),
nullptr);
197 return _names[index];
206 return _names.size();
216 out <<
"1 InternalName";
227 write(std::ostream &out,
int indent_level)
const {
void clear()
Removes all InternalNames from the collection.
get_num_names
Returns the number of InternalNames in the collection.
void add_names_from(const InternalNameCollection &other)
Adds all the InternalNames indicated in the other collection to this name.
bool remove_name(const InternalName *name)
Removes the indicated InternalName from the collection.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
void write(std::ostream &out, int indent_level=0) const
Writes a complete multi-line description of the InternalNameCollection to the indicated output stream...
Encodes a string name in a hash table, mapping it to a pointer.
void remove_names_from(const InternalNameCollection &other)
Removes from this collection all of the InternalNames listed in the other collection.
void add_name(const InternalName *name)
Adds a new InternalName to the collection.
get_name
Returns the nth InternalName in the collection.
void output(std::ostream &out) const
Writes a brief one-line description of the InternalNameCollection to the indicated output stream.
bool has_name(const InternalName *name) const
Returns true if the indicated InternalName appears in this collection, false otherwise.
const InternalName * operator [](int index) const
Returns the nth InternalName in the collection.
void remove_duplicate_names()
Removes any duplicate entries of the same InternalNames on this collection.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int size() const
Returns the number of names in the collection.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.