123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package psoAlgoCode;
- import java.util.Vector;
- public class Coordinate<T> {
- private Vector<T> coord;
- public Coordinate() {
- coord = new Vector<T>();
- }
- // Getter
- /**
- * Vector for coordinates
- *
- * @return the vector of all coordinates. It's size usually depends on the
- * dimension constant
- */
- public Vector<T> getCoords() {
- return coord;
- }
- /**
- * One object within the coord vector
- *
- * @param index
- * coord to be founded
- * @return the object corresponding the index
- */
- public T getCoord(int index) {
- return coord.get(index);
- }
- // Setter
- public void setCoords(Vector<T> new_coords) {
- this.coord = new_coords;
- }
- public void setCoord(T new_coord, int index) {
- coord.add(index, new_coord);
- }
- @Override
- public String toString() {
- String text = "";
- for (T v : coord) {
- text = text + v.toString();
- }
- return text;
- }
- }
|