RepastHPC  2.3.1
RelativeLocation.h
1 /*
2  * Repast for High Performance Computing (Repast HPC)
3  *
4  * Copyright (c) 2010 Argonne National Laboratory
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with
8  * or without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * Neither the name of the Argonne National Laboratory nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
25  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE TRUSTEES OR
26  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
32  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  *
35  * RelativeLocation.h
36  *
37  * Created on: July 28, 2015
38  * Author: jtm
39  */
40 
41 #ifndef RELATIVELOCATION_H_
42 #define RELATIVELOCATION_H_
43 
44 #include <vector>
45 
46 using namespace std;
47 
48 namespace repast {
49 
104 
105 public:
112  static int getDirectionIndex(vector<int> dirVec);
113 
121  static int getReverseDirectionIndex(vector<int> dirVec);
122 
123 private:
124  vector<int> currentValue;
125  vector<int> minima;
126  vector<int> maxima;
127  int countOfDimensions;
128  vector<int> places;
129  int maxIndex; // Memoize
130  int indexOfCenter; // Memoize
131 
132  void setPlaces();
133 
134 public:
135 
141  RelativeLocation(int dimensions);
142 
153  RelativeLocation(vector<int> minima, vector<int> maxima);
154 
158  RelativeLocation(const RelativeLocation& original);
159 
160  void translate(vector<int> displacement);
161 
162  virtual ~RelativeLocation();
163 
164  /*
165  * Increments this RelativeLocation instance.
166  * Returns false if the instance is already at its
167  * maximum (but will also roll over to minimum values!)
168  */
169  bool increment();
170 
171  bool increment(bool skipZero);
172 
173 
180  bool set(vector<int> newValues);
181 
190  bool equals(RelativeLocation other);
191 
195  vector<int> getCurrentValue();
196 
200  int operator[](int index);
201 
205  int getCountOfDimensions();
206 
211  int getMaxIndex();
212 
217  int getTotalValues();
218 
223  int getIndex(vector<int> value);
224 
229  int getIndex();
230 
234  int getIndexOfCenter();
235 
236 
241  bool validNonCenter();
242 
247  int getMinimumAt(int index);
248 
253  int getMaximumAt(int index);
254 
273  RelativeLocation trim(RelativeLocation toBeTrimmed);
274 
279  std::string report();
280 };
281 
282 }
283 
284 #endif /* DIFFUSIONLAYERND_H_ */
repast::RelativeLocation
A RelativeLocation is a vector of integers that express a relative location in a coordinate system; t...
Definition: RelativeLocation.h:103