Panda3D
Loading...
Searching...
No Matches
eggMorphList.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file eggMorphList.I
10 * @author drose
11 * @date 1999-01-29
12 */
13
14/**
15 *
16 */
17template<class MorphType>
20}
21
22/**
23 *
24 */
25template<class MorphType>
28 _morphs(copy._morphs)
29{
30}
31
32/**
33 *
34 */
35template<class MorphType>
37operator = (const EggMorphList &copy) {
38 _morphs = copy._morphs;
39}
40
41/**
42 *
43 */
44template<class MorphType>
47}
48
49/**
50 *
51 */
52template<class MorphType>
54operator == (const EggMorphList<MorphType> &other) const {
55 return (_morphs == other._morphs);
58/**
59 *
60 */
61template<class MorphType>
63operator != (const EggMorphList<MorphType> &other) const {
64 return (_morphs != other._morphs);
65}
66
67/**
68 *
69 */
70template<class MorphType>
72operator < (const EggMorphList<MorphType> &other) const {
73 return (_morphs < other._morphs);
74}
75
76/**
77 * compare_to() compares a different space than the operator methods, which
78 * only check the morph's name. compare_to() compares the name and the value
79 * as well.
80 */
81template<class MorphType>
83compare_to(const EggMorphList<MorphType> &other, double threshold) const {
84 if (_morphs.size() != other._morphs.size()) {
85 return (int)_morphs.size() - (int)other._morphs.size();
86 }
87 for (size_t i = 0; i < _morphs.size(); i++) {
88 int compare = _morphs[i].compare_to(other._morphs[i], threshold);
89 if (compare < 0) {
90 return compare;
91 }
92 }
93 return 0;
94}
95
96/**
97 *
98 */
99template<class MorphType>
100INLINE typename EggMorphList<MorphType>::iterator EggMorphList<MorphType>::
101begin() {
102 return _morphs.begin();
103}
104
105/**
106 *
107 */
108template<class MorphType>
109INLINE typename EggMorphList<MorphType>::const_iterator EggMorphList<MorphType>::
110begin() const {
111 return _morphs.begin();
112}
113
114/**
115 *
116 */
117template<class MorphType>
118INLINE typename EggMorphList<MorphType>::iterator EggMorphList<MorphType>::
119end() {
120 return _morphs.end();
121}
122
123/**
124 *
125 */
126template<class MorphType>
127INLINE typename EggMorphList<MorphType>::const_iterator EggMorphList<MorphType>::
128end() const {
129 return _morphs.end();
130}
131
132/**
133 *
134 */
135template<class MorphType>
136INLINE typename EggMorphList<MorphType>::size_type EggMorphList<MorphType>::
137size() const {
138 return _morphs.size();
139}
140
141/**
142 *
143 */
144template<class MorphType>
146empty() const {
147 return _morphs.empty();
148}
149
150/**
151 * This is similar to the insert() interface for sets, except it does not
152 * guarantee that the resulting list is sorted.
153 *
154 * We have this member function so the EggMorphList resembles a set. It used
155 * to *be* a set, but we cannot export STL sets from a Windows DLL.
156 */
157template<class MorphType>
158std::pair<typename EggMorphList<MorphType>::iterator, bool> EggMorphList<MorphType>::
159insert(const MorphType &value) {
160 std::pair<iterator, bool> result;
161 typename Morphs::iterator mi;
162 for (mi = _morphs.begin(); mi != _morphs.end(); ++mi) {
163 if ((*mi) == value) {
164 // This value is already present.
165 result.first = mi;
166 result.second = false;
167 return result;
168 }
169 }
170
171 // This value is not already present; add it to the list.
172 _morphs.push_back(value);
173 result.first = _morphs.begin() + _morphs.size() - 1;
174 result.second = true;
175 return result;
176}
177
178/**
179 * Empties the list of morphs.
180 */
181template<class MorphType>
183clear() {
184 _morphs.clear();
185}
186
187/**
188 *
189 */
190template<class MorphType>
192write(std::ostream &out, int indent_level, const std::string &tag,
193 int num_dimensions) const {
194 const_iterator i;
195
196 for (i = begin(); i != end(); ++i) {
197 indent(out, indent_level);
198 i->output(out, tag, num_dimensions);
199 out << "\n";
200 }
201}
A collection of <Dxyz>'s or <Duv>'s or some such.
void clear()
Empties the list of morphs.
int compare_to(const EggMorphList< MorphType > &other, double threshold) const
compare_to() compares a different space than the operator methods, which only check the morph's name.
std::pair< iterator, bool > insert(const MorphType &value)
This is similar to the insert() interface for sets, except it does not guarantee that the resulting l...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20