15 #include "internalNameCollection.h" 24 InternalNameCollection::
25 InternalNameCollection() {
33 InternalNameCollection::
44 void InternalNameCollection::
61 if (_names.get_ref_count() > 1) {
62 InternalNames old_names = _names;
63 _names = InternalNames::empty_array(0);
64 _names.v() = old_names.v();
67 _names.push_back(name);
80 for (
int i = 0; name_index == -1 && i < (int)_names.size(); i++) {
81 if (_names[i] == name) {
86 if (name_index == -1) {
96 if (_names.get_ref_count() > 1) {
97 InternalNames old_names = _names;
98 _names = InternalNames::empty_array(0);
99 _names.v() = old_names.v();
102 _names.erase(_names.begin() + name_index);
117 for (
int i = 0; i < other_num_names; i++) {
131 InternalNames new_names;
133 for (
int i = 0; i < num_names; i++) {
134 const InternalName *name =
get_name(i);
136 new_names.push_back(name);
152 InternalNames new_names;
155 for (
int i = 0; i < num_names; i++) {
156 const InternalName *name =
get_name(i);
157 bool duplicated =
false;
159 for (
int j = 0; j < i && !duplicated; j++) {
164 new_names.push_back(name);
204 return _names.size();
214 nassertr(index >= 0 && index < (
int)_names.size(), NULL);
216 return _names[index];
228 nassertr(index >= 0 && index < (
int)_names.size(), NULL);
230 return _names[index];
241 return _names.size();
253 out <<
"1 InternalName";
266 write(ostream &out,
int indent_level)
const {
268 indent(out, indent_level) << *
get_name(i) <<
"\n";
const InternalName * operator[](int index) const
Returns the nth InternalName in the collection.
int get_num_names() const
Returns the number of InternalNames in the collection.
void write(ostream &out, int indent_level=0) const
Writes a complete multi-line description of the InternalNameCollection to the indicated output stream...
void clear()
Removes all InternalNames from the collection.
void output(ostream &out) const
Writes a brief one-line description of the InternalNameCollection to the indicated output stream...
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.
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.
bool has_name(const InternalName *name) const
Returns true if the indicated InternalName appears in this collection, false otherwise.
void remove_duplicate_names()
Removes any duplicate entries of the same InternalNames on this collection.
const InternalName * get_name(int index) const
Returns the nth InternalName in the collection.
int size() const
Returns the number of names in the collection.