Coordinate.java 894 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package psoAlgoCode;
  2. import java.util.Vector;
  3. public class Coordinate<T> {
  4. private Vector<T> coord;
  5. public Coordinate() {
  6. coord = new Vector<T>();
  7. }
  8. // Getter
  9. /**
  10. * Vector for coordinates
  11. *
  12. * @return the vector of all coordinates. It's size usually depends on the
  13. * dimension constant
  14. */
  15. public Vector<T> getCoords() {
  16. return coord;
  17. }
  18. /**
  19. * One object within the coord vector
  20. *
  21. * @param index
  22. * coord to be founded
  23. * @return the object corresponding the index
  24. */
  25. public T getCoord(int index) {
  26. return coord.get(index);
  27. }
  28. // Setter
  29. public void setCoords(Vector<T> new_coords) {
  30. this.coord = new_coords;
  31. }
  32. public void setCoord(T new_coord, int index) {
  33. coord.add(index, new_coord);
  34. }
  35. @Override
  36. public String toString() {
  37. String text = "";
  38. for (T v : coord) {
  39. text = text + v.toString();
  40. }
  41. return text;
  42. }
  43. }