1 #ifndef __JTOOLS__JCOLLECTION__
2 #define __JTOOLS__JCOLLECTION__
72 template<
class JElement_t,
class JDistance_t = JDistance<
typename JElement_t::abscissa_type> >
76 typename JElement_t::ordinate_type>,
78 public JMath< JCollection<JElement_t, JDistance_t> >
93 typedef typename container_type::iterator
iterator;
114 const JElement_t& second)
const
116 return this->
getDistance(first.getX(), second.getX()) > 0.0;
152 container_type::clear();
166 if (i == this->end() || this->
getDistance(x, i->getX()) > distance_type::precision) {
184 if (i == this->end() || this->
getDistance(x, i->getX()) > distance_type::precision) {
185 i = container_type::insert(i,
value_type(
x, JMATH::getZero<ordinate_type>()));
199 return (
int) this->size();
211 return this->at(index).getX();
222 return this->begin()->getX();
233 return this->rbegin()->getX();
246 return this->at(index).getY();
258 return this->at(index).getY();
269 for (
iterator i = this->begin(); i != this->end(); ++i) {
270 *i = transformer(*i);
282 std::sort(this->begin(), this->end(),
compare);
294 return std::lower_bound(this->begin(), this->end(),
x,
compare);
306 return std::lower_bound(this->begin(), this->end(),
x,
compare);
320 if (i == this->end() || this->
getDistance(element.getX(), i->getX()) > 0.0)
321 return pair_type(container_type::insert(i, element),
true);
334 configure(bounds, JMATH::getZero<ordinate_type>());
349 for (
iterator i = this->begin(); i != this->end(); ++i) {
364 template<
class JFunction1D_t>
366 const JFunction1D_t&
function)
368 using namespace JLANG;
372 for (
int i = 0; i != bounds.
getSize(); ++i) {
376 out->
put(
x,
function(
x));
396 if (this->empty() || collection.empty()) {
407 if (
getDistance(p->getX(), q->getX()) > precision) {
411 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
413 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
417 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
420 for ( ; p != this->end() && q != collection.end(); ++p, ++q) {
421 if (fabs(
getDistance(p->getX(), q->getX())) > precision) {
438 for (
iterator i = this->begin(); i != this->end(); ++i) {
439 i->
getY() = -i->getY();
454 if (!collection.empty()) {
458 for (
const_iterator i = collection.begin(); i != collection.end(); ++i) {
459 this->
put(i->getX(), +i->getY());
469 if (
getDistance(p->getX(), q->getX()) > precision) {
473 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
475 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
479 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
484 for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
485 p->
getY() += i->getY();
488 for ( ; i != collection.end(); ++i) {
489 this->
put(i->getX(), +i->getY());
492 for (i = collection.begin(); i != q; ++i) {
493 this->
put(i->getX(), +i->getY());
510 if (!collection.empty()) {
514 for (
const_iterator i = collection.begin(); i != collection.end(); ++i) {
515 this->
put(i->getX(), -i->getY());
525 if (
getDistance(p->getX(), q->getX()) > precision) {
529 }
while (p != this->end() &&
getDistance(p->getX(), q->getX()) > precision);
531 }
else if (
getDistance(q->getX(), p->getX()) > precision) {
535 }
while (q != collection.end() &&
getDistance(q->getX(), p->getX()) > precision);
540 for ( ; p != this->end() && i != collection.end(); ++p, ++i) {
541 p->
getY() -= i->getY();
544 for ( ; i != collection.end(); ++i) {
545 this->
put(i->getX(), -i->getY());
548 for (i = collection.begin(); i != q; ++i) {
549 this->
put(i->getX(), -i->getY());
570 for (
iterator i = this->begin(); i != this->end(); ++i) {
586 for (
iterator i = this->begin(); i != this->end(); ++i) {
602 for (
iterator i = this->begin(); i != this->end(); ++i) {
618 for (
iterator i = this->begin(); i != this->end(); ++i) {
632 template<
class JFunction1D_t>
635 for (
iterator i = this->begin(); i != this->end(); ++i) {
636 i->
getY() +=
function(i->getX());
649 template<
class JFunction1D_t>
652 for (
iterator i = this->begin(); i != this->end(); ++i) {
653 i->
getY() -=
function(i->getX());
669 return collection.
add(value);
682 return collection.
sub(value);
693 template<
class JFunction1D_t>
696 return collection.
add(
function);
707 template<
class JFunction1D_t>
710 return collection.
sub(
function);
747 const int n = collection.size();
788 void resize(
typename container_type::size_type size)
790 container_type::resize(size);
809 template<
class JElement_t,
811 inline typename JElement_t::ordinate_type
821 output.
put(input.begin()->
getX(), V);
825 V += 0.5 * input.
getDistance(i->getX(),
j->getX()) * (i->getY() +
j->getY());
827 output.
put(
j->getX(), V);
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Base class for data structures with artithmetic capabilities.
Definition of zero value for any class.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Interface for binary input.
Interface for binary output.
Exception for accessing a value in a collection that is outside of its range.
Auxiliary classes and methods for language specific functionality.
bool is_identical(JFirst_t &first, JSecond_t &second)
Check if two objects are indentical.
static const JZero zero
Function object to assign zero value.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Template for generic class types.
JArgument< T >::argument_type argument_type
Auxiliary base class for aritmetic operations of derived class types.