1#include "KVNumberList.h"
23 fFirstValue = 99999999;
24 fLastValue = -99999999;
108 for (
auto i :
L)
Add(i);
191 std::unique_ptr<TObjArray> toks1(
string.Tokenize(delim));
192 Int_t n_toks = toks1->GetEntries();
193 for (
int i = 0; i < n_toks; i++) {
223 std::unique_ptr<TObjArray> toks1(
string.Tokenize(
'-'));
224 Int_t n_toks = toks1->GetEntries();
225 if (n_toks != 2)
return;
275 std::cout <<
"KVNumberList::" <<
GetName() << std::endl;
276 std::cout <<
"There are " <<
fNLimits <<
" limits in the string : " <<
278 std::cout <<
"MIN = ";
279 for (
int i = 0; i <
fNLimits; i++) {
284 std::cout << std::endl;
285 std::cout <<
"MAX = ";
286 for (
int i = 0; i <
fNLimits; i++) {
291 std::cout << std::endl;
292 std::cout <<
"First value = " <<
fFirstValue <<
" Last value = " <<
317 return !((*this) == other);
345 for (
int i = 0; i <
fNLimits; i++) {
399 for (
int i = 0; i <
fNLimits; i++) {
402 for (
int j =
min; j <=
max; j++) {
409 IntArrayIter beg = temp.begin();
410 std::sort(beg, temp.end());
411 IntArrayIter
end = std::unique(beg, temp.end());
412 Int_t n_uniq = std::distance(beg,
end);
514 for (
int i = 0; i <
n; i++) {
531 for (IntArrayCIter it =
v.begin(); it !=
v.end(); ++it) {
562 for (
int i = 0; i <
n; i++) {
579 for (
int i =
min; i <=
max; i += pas) {
605 while (!tampon.
End()) {
645 IntArrayIter it = arr.begin();
649 for (++it; it != arr.end(); ++it) {
653 if (val - * (it - 1) > 1) {
704 IntArrayIter it = arr.begin();
705 for (; it != arr.end() - 1; ++it) {
708 tmp +=
Form(
"%d ", val);
711 tmp +=
Form(
"%d", val);
735 std::unique_ptr<TObjArray> toks(tmp.
Tokenize(
"||"));
738 Int_t nt = toks->GetEntries();
739 for (
Int_t ii = 0; ii < nt; ii += 1) {
741 if (
line.Contains(
"-")) {
742 line.ReplaceAll(
"-",
Form(
"<=%s&&%s<=", observable, observable));
746 cond +=
Form(
"%s==", observable) +
line;
748 if (ii != nt - 1) cond +=
"||";
777 if (cond !=
"") cond +=
" OR ";
780 cond += (qcol +
" BETWEEN ");
787 cond += (qcol +
"=");
855 Warning(
"Next",
"List is empty. -1 returned.");
859 Warning(
"Next",
"Attempt to iterate beyond end of list. -1 returned.");
956 catch (std::exception&
e) {
957 Warning(KV__ERROR(
At),
"Index out of bounds. -1 returned.");
1009 Int_t len_left = maxlen - 3;
1010 Int_t len_start = len_left / 2;
1011 Int_t len_end = len_left - len_start;
1054 for (
int ii = 0; ii < nws - 1; ii++)
fTMPSTR +=
Form(
"%s%s", tmp.
Next().
Data(), (ii == nws - 2) ?
"" :
", ");
1155 if ((vinf == -1) && (vsup == -1)) {
1204 if (vinf > vsup)
return nl;
1205 if (vinf == -1) vinf =
First();
1206 if (vsup == -1) vsup =
Last();
1210 if (val >= vinf && val <= vsup) nl.
Add(val);
1211 else if (val > vsup)
return nl;
winID h TVirtualViewer3D vv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
Strings used to represent a set of ranges of values.
TList * CutInSubList(Int_t number)
Int_t GetRandomFast() const
bool operator!=(const KVNumberList &) const
Inequality test for number lists.
void Inter(const KVNumberList &list)
void Copy(TObject &) const
Copy content of this number list into 'o'.
virtual void SetName(const char *name)
Int_t fNLimits
number of limits in arrays
const Char_t * AsQuotedString() const
const Char_t * GetList() const
Bool_t Contains(Int_t val) const
returns kTRUE if the value 'val' is contained in the ranges defined by the number list
KVNumberList()
Default constructor.
Int_t First() const
Returns smallest number included in list.
virtual const char * GetName() const
void SetMinMax(Int_t min, Int_t max, Int_t pas=1)
Set list with all values from 'min' to 'max'.
void Print(Option_t *="") const
KVNumberList operator+(const KVNumberList &) const
Return sum of this list and the other one.
const Char_t * AsString(Int_t maxchars=0) const
void Remove(Int_t)
Remove value 'n' from the list.
IntArrayIter begin() const
IntArray fRandomFastArray
used by GetRandomFast()
const Char_t * AsHumanReadableString() const
Int_t fFirstValue
smallest value included in list
const Char_t * GetExpandedList() const
KVNumberList operator-(const KVNumberList &) const
TString fTMPSTR
dummy string to compute AsString (non static)
Bool_t IsFull(Int_t vinf=-1, Int_t vsup=-1) const
TString fName
name of the list
Int_t fMaxNLimits
size of arrays
void SetList(const TString &)
void Add(Int_t)
Add value 'n' to the list.
IntArrayIter fEndList
used by Next() & End() to iterate over list
void AddLimits(Int_t min, Int_t max)
IntArrayIter fIterIndex
used by Next() to iterate over list
IntArray fValues
used by Next() to iterate over list
void Clear(Option_t *="")
Empty number list, reset it to initial state.
bool operator==(const KVNumberList &) const
Equality test for number lists.
void ParseAndFindLimits(const TString &string, const Char_t delim)
Int_t fLastValue
largest value included in list
IntArray GetArray() const
TString GetSQL(const Char_t *column) const
Int_t At(Int_t index) const
Bool_t PrepareRandomFast() const
KVNumberList GetSubList(Int_t vinf, Int_t vsup) const
Int_t operator[](Int_t index) const
KVNumberList GetComplementaryList() const
Int_t Last() const
Returns largest number included in list.
void clear()
private method called by ParseList()
TString GetLogical(const Char_t *observable) const
Int_t fNValues
total number of values included in ranges
void init_numberlist()
Default initialisation used by ctors.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
Int_t GetNValues(TString delim) const
void Set(Int_t n) override
virtual void SetOwner(Bool_t enable=kTRUE)
void Add(TObject *obj) override
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual UInt_t Integer(UInt_t imax)
const char * Data() const
TObjArray * Tokenize(const TString &delim) const
TString & Append(char c, Ssiz_t rep=1)
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
Column in an SQLite database.
RooCmdArg ClassName(const char *name)
RooArgList L(Args_t &&... args)
double min(double x, double y)
double max(double x, double y)
Double_t Max(Double_t a, Double_t b)