OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
ListElem.h
Go to the documentation of this file.
1#ifndef LISTEELEM
2#define LISTEELEM
3
4/*
5Andreas Adelmann & Arno Candel
6Paul Scherrer Institut PSI
7
8$Header: /afs/psi.ch/user/a/adelmann/public/cvsroot/ChargedParticles/ListElem.h,v 1.4 2001/08/16 15:22:35 arno Exp $
9$Id: ListElem.h,v 1.4 2001/08/16 15:22:35 arno Exp $
10$Locker: $
11
12$Revision: 1.4 $
13$State: Exp $
14$Date: 2001/08/16 15:22:35 $
15
16$Log: ListElem.h,v $
17Revision 1.4 2001/08/16 15:22:35 arno
18added ouput of Planar Projections, thus new ListElem needed, with 2 indices
19
20Revision 1.3 2001/08/14 08:30:35 candel
21List output only from 1 to N-1, assures centered R plots
22
23Revision 1.2 2001/08/11 05:46:40 adelmann
24Add header with CVS tags
25
26add << operator
27
28
29*/
30
31#include <list>
32#include <string>
33#include <fstream>
34
35class ListElem {
36public:
37 ListElem(double sval, double tval, unsigned int mval, unsigned int nval, double denval) :
38 s(sval),
39 t(tval),
40 m(mval),
41 n(nval),
42 den(denval)
43 {}
44
46 {}
47
48
49 bool operator< (const ListElem &elem) const {
50 return ((m < elem.m) && (n <= elem.n));
51 }
52
53 void print(Inform os, const std::list<ListElem> &l) {
54 unsigned int mmax = 0;
55 unsigned int nmax = 0;
56 for(std::list<ListElem>::const_iterator it = l.begin(); it != l.end() ; ++it) {
57 if(it->m > mmax) mmax = it->m;
58 if(it->n > nmax) nmax = it->n;
59 }
60
61 for(std::list<ListElem>::const_iterator it = l.begin(); it != l.end(); ++it)
62 if((it->m < mmax) && (it->n < nmax)) {
63 os << it->s << " " << it->t << " " << it->m << " " << it->n << " " << it->den << endl;
64 }
65 }
66
67 double s;
68 double t;
69 unsigned int m, n;
70 double den;
71};
72/*
73ofstream& operator<<(ofstream& os, const list<ListElem> &l)
74{
75 unsigned int mmax=0;
76 unsigned int nmax=0;
77 for(list<ListElem>::const_iterator it=l.begin(); it!=l.end() ;++it) {
78 if (it->m > mmax) mmax=it->m;
79 if (it->n > nmax) nmax=it->n;
80 }
81
82 for(list<ListElem>::const_iterator it=l.begin();it!=l.end();++it)
83 if ((it->m < mmax)&&(it->n < nmax)) {
84 os << it->s << " " << it->t << " " << it->m << " " << it->n << " " << it->den << endl;
85 }
86 return os;
87}
88*/
89#endif
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
double den
Definition: ListElem.h:70
~ListElem()
Definition: ListElem.h:45
ListElem(double sval, double tval, unsigned int mval, unsigned int nval, double denval)
Definition: ListElem.h:37
double t
Definition: ListElem.h:68
unsigned int m
Definition: ListElem.h:69
bool operator<(const ListElem &elem) const
Definition: ListElem.h:49
unsigned int n
Definition: ListElem.h:69
void print(Inform os, const std::list< ListElem > &l)
Definition: ListElem.h:53
double s
Definition: ListElem.h:67
Definition: Inform.h:42