Jpp  19.1.0
the software that should make you happy
Public Types | Public Member Functions | Friends | List of all members
JTOOLS::JSet< JAbscissa_t > Struct Template Reference

Simple data structure for an abstract collection of non-equidistant abscissa values. More...

#include <JSet.hh>

Inheritance diagram for JTOOLS::JSet< JAbscissa_t >:
JTOOLS::JAbstractCollection< JAbscissa_t > std::set< JAbscissa_t >

Public Types

typedef JAbstractCollection< JAbscissa_t >::abscissa_type abscissa_type
 

Public Member Functions

 JSet ()
 Default constructor. More...
 
 JSet (const JAbstractCollection< abscissa_type > &collection)
 Constructor. More...
 
template<class T >
 JSet (T __begin, T __end)
 Constructor. More...
 
virtual int getSize () const override
 Get number of elements. More...
 
virtual abscissa_type getX (int index) const override
 Get abscissa value. More...
 
virtual abscissa_type getXmin () const override
 Get minimal abscissa value. More...
 
virtual abscissa_type getXmax () const override
 Get maximal abscissa value. More...
 
template<class JElement_t , class JDistance_t >
const JSetoperator() (JCollection< JElement_t, JDistance_t > &collection) const
 Configure collection. More...
 
bool is_equal (const JAbstractCollection &collection) const
 Test whether abstract collections are equal. More...
 

Friends

std::istream & operator>> (std::istream &in, JSet< JAbscissa_t > &object)
 Read set from input. More...
 
std::ostream & operator<< (std::ostream &out, const JSet< JAbscissa_t > &object)
 Write set to output. More...
 

Detailed Description

template<class JAbscissa_t>
struct JTOOLS::JSet< JAbscissa_t >

Simple data structure for an abstract collection of non-equidistant abscissa values.

This class implements the JAbstractCollection interface.

Definition at line 31 of file JSet.hh.

Member Typedef Documentation

◆ abscissa_type

template<class JAbscissa_t >
typedef JAbstractCollection<JAbscissa_t>::abscissa_type JTOOLS::JSet< JAbscissa_t >::abscissa_type

Definition at line 35 of file JSet.hh.

Constructor & Destructor Documentation

◆ JSet() [1/3]

template<class JAbscissa_t >
JTOOLS::JSet< JAbscissa_t >::JSet ( )
inline

Default constructor.

Definition at line 41 of file JSet.hh.

42  {}

◆ JSet() [2/3]

template<class JAbscissa_t >
JTOOLS::JSet< JAbscissa_t >::JSet ( const JAbstractCollection< abscissa_type > &  collection)
inline

Constructor.

Parameters
collectionabstract collection

Definition at line 50 of file JSet.hh.

51  {
52  for (int i = 0; i != collection.getSize(); ++i) {
53  this->insert(collection.getX(i));
54  }
55  }
virtual int getSize() const =0
Get number of elements.
virtual abscissa_type getX(int index) const =0
Get abscissa value.

◆ JSet() [3/3]

template<class JAbscissa_t >
template<class T >
JTOOLS::JSet< JAbscissa_t >::JSet ( __begin,
__end 
)
inline

Constructor.

Parameters
__beginbegin of abscissa values
__endend of abscissa values

Definition at line 65 of file JSet.hh.

66  {
67  for (T i = __begin; i != __end; ++i) {
68  this->insert(*i);
69  }
70  }

Member Function Documentation

◆ getSize()

template<class JAbscissa_t >
virtual int JTOOLS::JSet< JAbscissa_t >::getSize ( ) const
inlineoverridevirtual

Get number of elements.

Returns
number of elements

Implements JTOOLS::JAbstractCollection< JAbscissa_t >.

Definition at line 78 of file JSet.hh.

79  {
80  return (int) this->size();
81  }

◆ getX()

template<class JAbscissa_t >
virtual abscissa_type JTOOLS::JSet< JAbscissa_t >::getX ( int  index) const
inlineoverridevirtual

Get abscissa value.

Parameters
indexindex
Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JAbscissa_t >.

Definition at line 90 of file JSet.hh.

91  {
92  typename std::set<abscissa_type>::const_iterator i = this->begin();
93 
94  std::advance(i, index);
95 
96  return *i;
97  }
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.

◆ getXmin()

template<class JAbscissa_t >
virtual abscissa_type JTOOLS::JSet< JAbscissa_t >::getXmin ( ) const
inlineoverridevirtual

Get minimal abscissa value.

Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JAbscissa_t >.

Definition at line 105 of file JSet.hh.

106  {
107  return *(this->begin());
108  }

◆ getXmax()

template<class JAbscissa_t >
virtual abscissa_type JTOOLS::JSet< JAbscissa_t >::getXmax ( ) const
inlineoverridevirtual

Get maximal abscissa value.

Returns
abscissa value

Implements JTOOLS::JAbstractCollection< JAbscissa_t >.

Definition at line 116 of file JSet.hh.

117  {
118  return *(this->rbegin());
119  }

◆ operator()()

template<class JAbscissa_t >
template<class JElement_t , class JDistance_t >
const JSet& JTOOLS::JSet< JAbscissa_t >::operator() ( JCollection< JElement_t, JDistance_t > &  collection) const
inline

Configure collection.

Parameters
collectioncollection
Returns
this set

Definition at line 129 of file JSet.hh.

130  {
131  collection.configure(*this);
132 
133  return *this;
134  }
void configure(const JAbstractCollection< abscissa_type > &bounds)
Configure collection.
Definition: JCollection.hh:332

◆ is_equal()

template<class JAbscissa_t >
bool JTOOLS::JAbstractCollection< JAbscissa_t >::is_equal ( const JAbstractCollection< JAbscissa_t > &  collection) const
inlineinherited

Test whether abstract collections are equal.

Parameters
collectionabstract collection
Returns
true if collections are equals; else false

Definition at line 72 of file JAbstractCollection.hh.

73  {
74  if (this->getSize() == collection.getSize()) {
75 
76  for (int i = 0; i != this->getSize(); ++i) {
77 
78  if (this->getX(i) != collection.getX(i)) {
79  return false;
80  }
81  }
82 
83  return true;
84  }
85 
86  return false;
87  }

Friends And Related Function Documentation

◆ operator>>

template<class JAbscissa_t >
std::istream& operator>> ( std::istream &  in,
JSet< JAbscissa_t > &  object 
)
friend

Read set from input.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 144 of file JSet.hh.

145  {
146  for (JAbscissa_t value; in >> value; ) {
147  object.insert(value);
148  }
149 
150  return in;
151  }

◆ operator<<

template<class JAbscissa_t >
std::ostream& operator<< ( std::ostream &  out,
const JSet< JAbscissa_t > &  object 
)
friend

Write set to output.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 161 of file JSet.hh.

162  {
163  for (typename JSet<JAbscissa_t>::const_iterator i = object.begin(); i != object.end(); ++i) {
164  out << ' ' << *i;
165  }
166 
167  return out;
168  }
Simple data structure for an abstract collection of non-equidistant abscissa values.
Definition: JSet.hh:34

The documentation for this struct was generated from the following file: