Panda3D
indexRemapper.cxx
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 indexRemapper.cxx
10  * @author drose
11  * @date 2000-08-05
12  */
13 
14 #include "indexRemapper.h"
15 
16 
17 /**
18  *
19  */
20 IndexRemapper::
21 IndexRemapper() {
22 }
23 
24 /**
25  *
26  */
27 IndexRemapper::
28 ~IndexRemapper() {
29 }
30 
31 /**
32  * Removes all mappings from the object.
33  */
34 void IndexRemapper::
35 clear() {
36  _map_int.clear();
37 }
38 
39 /**
40  * Adds a mapping from the integer 'from' to 'to'.
41  */
42 void IndexRemapper::
43 add_mapping(int from, int to) {
44  _map_int[from] = to;
45 }
46 
47 /**
48  * Returns true if the given 'from' integer has been assigned a mapping, false
49  * if it has not.
50  */
51 bool IndexRemapper::
52 in_map(int from) const {
53  return _map_int.count(from) != 0;
54 }
55 
56 /**
57  * Returns the integer that the given 'from' integer had been set to map to,
58  * or the same integer if nothing had been set for it.
59  */
61 map_from(int from) const {
62  std::map<int, int>::const_iterator mi;
63  mi = _map_int.find(from);
64  if (mi == _map_int.end()) {
65  return from;
66  }
67  return (*mi).second;
68 }
void clear()
Removes all mappings from the object.
bool in_map(int from) const
Returns true if the given 'from' integer has been assigned a mapping, false if it has not.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void add_mapping(int from, int to)
Adds a mapping from the integer 'from' to 'to'.
int map_from(int from) const
Returns the integer that the given 'from' integer had been set to map to, or the same integer if noth...