Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package fap.core.data;
  2.  
  3. import java.util.Collection;
  4. import java.util.Iterator;
  5. import java.util.List;
  6.  
  7. /**
  8. * A serie of input data.
  9. *
  10. * @author Aleksa Todorovic
  11. * @version 1.0
  12. */
  13. public abstract class DataPointSerie implements Iterable<DataPoint> {
  14.  
  15. /**
  16. * Default constructor.
  17. */
  18. public DataPointSerie() {
  19. }
  20.  
  21. /**
  22. * Constructor from collection.
  23. * @param C collection of points
  24. */
  25. public DataPointSerie(Collection<? extends DataPoint> C) {
  26. clear();
  27. getPoints().addAll(C);
  28. }
  29.  
  30. /**
  31. * List of points.
  32. * @return List of points in this serie data
  33. */
  34. protected abstract List<DataPoint> getPoints();
  35.  
  36. /**
  37. * Number of points.
  38. * @return number of points in this serie data
  39. */
  40. public int getPointsCount() {
  41. return getPoints().size();
  42. }
  43.  
  44. /**
  45. * Get i-th point.
  46. * @param i index of point to return
  47. * @return value of i-th point
  48. */
  49. public DataPoint getPoint(int i) {
  50. return getPoints().get(i);
  51. }
  52.  
  53. /**
  54. * Clears points collection.
  55. */
  56. public void clear() {
  57. getPoints().clear();
  58. }
  59.  
  60. /**
  61. * Adds point to points collection.
  62. * @param point new point to add
  63. */
  64. public void addPoint(DataPoint point) {
  65. getPoints().add(point);
  66. }
  67.  
  68. /**
  69. * New iterator over points in this serie data.
  70. * @return iterator over points
  71. */
  72. public Iterator<DataPoint> iterator() {
  73. return getPoints().iterator();
  74. }
  75.  
  76. /**
  77. * Array of points in this serie data.
  78. * @return new array with points from this serie data
  79. */
  80. public DataPoint[] getPointsArray() {
  81. return getPoints().toArray(new DataPoint[getPoints().size()]);
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement