Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JAbstractCollection.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JABSTRACTCOLLECTION__
2 #define __JTOOLS__JABSTRACTCOLLECTION__
3 
4 
5 /**
6  * \author mdejong
7  */
8 
9 namespace JTOOLS {}
10 namespace JPP { using namespace JTOOLS; }
11 
12 namespace JTOOLS {
13 
14  /**
15  * Abstract interface for abscissa values of a collection of elements.
16  */
17  template<class JAbscissa_t>
19 
20  typedef JAbscissa_t abscissa_type;
21 
22 
23  /**
24  * Virtual destructor.
25  */
27  {}
28 
29 
30  /**
31  * Get number of elements.
32  *
33  * \return number of elements
34  */
35  virtual int getSize() const = 0;
36 
37 
38  /**
39  * Get abscissa value.
40  *
41  * \param index index
42  * \return abscissa value
43  */
44  virtual abscissa_type getX(int index) const = 0;
45 
46 
47  /**
48  * Get minimal abscissa value.
49  *
50  * \return abscissa value
51  */
52  virtual abscissa_type getXmin() const = 0;
53 
54 
55  /**
56  * Get maximal abscissa value.
57  *
58  * \return abscissa value
59  */
60  virtual abscissa_type getXmax() const = 0;
61 
62 
63  /**
64  * Test whether abstract collections are equal.
65  *
66  * \param collection abstract collection
67  * \return true if collections are equals; else false
68  */
69  bool is_equal(const JAbstractCollection& collection) const
70  {
71  if (this->getSize() == collection.getSize()) {
72 
73  for (int i = 0; i != this->getSize(); ++i) {
74 
75  if (this->getX(i) != collection.getX(i)) {
76  return false;
77  }
78  }
79 
80  return true;
81  }
82 
83  return false;
84  }
85  };
86 }
87 
88 #endif
Abstract interface for abscissa values of a collection of elements.
virtual abscissa_type getXmin() const =0
Get minimal abscissa value.
bool is_equal(const JAbstractCollection &collection) const
Test whether abstract collections are equal.
virtual ~JAbstractCollection()
Virtual destructor.
virtual abscissa_type getX(int index) const =0
Get abscissa value.
virtual abscissa_type getXmax() const =0
Get maximal abscissa value.
virtual int getSize() const =0
Get number of elements.