/usr/include/root/TOrdCollection.h is in libroot-core-dev 5.34.19+dfsg-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | // @(#)root/cont:$Id$
// Author: Fons Rademakers 13/09/95
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TOrdCollection
#define ROOT_TOrdCollection
//////////////////////////////////////////////////////////////////////////
// //
// TOrdCollection //
// //
// Ordered collection. //
// //
//////////////////////////////////////////////////////////////////////////
#ifndef ROOT_TSeqCollection
#include "TSeqCollection.h"
#endif
#include <iterator>
class TOrdCollectionIter;
class TOrdCollection : public TSeqCollection {
friend class TOrdCollectionIter;
private:
TObject **fCont;
Int_t fCapacity;
Int_t fGapStart;
Int_t fGapSize;
Int_t PhysIndex(Int_t idx) const;
Int_t LogIndex(Int_t idx) const;
void MoveGapTo(Int_t newGapStart);
Bool_t IllegalIndex(const char *method, Int_t idx) const;
void Init(Int_t capacity);
Bool_t LowWaterMark() const;
void SetCapacity(Int_t newCapacity);
TOrdCollection(const TOrdCollection&); // Not implemented
TOrdCollection& operator=(const TOrdCollection&); // Not implemented
public:
enum { kDefaultCapacity = 1, kMinExpand = 8, kShrinkFactor = 2 };
typedef TOrdCollectionIter Iterator_t;
TOrdCollection(Int_t capacity = kDefaultCapacity);
~TOrdCollection();
void Clear(Option_t *option="");
void Delete(Option_t *option="");
TObject **GetObjectRef(const TObject *obj) const;
Int_t IndexOf(const TObject *obj) const;
TIterator *MakeIterator(Bool_t dir = kIterForward) const;
void AddFirst(TObject *obj);
void AddLast(TObject *obj);
void AddAt(TObject *obj, Int_t idx);
void AddAfter(const TObject *after, TObject *obj);
void AddBefore(const TObject *before, TObject *obj);
void PutAt(TObject *obj, Int_t idx);
TObject *RemoveAt(Int_t idx);
TObject *Remove(TObject *obj);
TObject *At(Int_t idx) const;
TObject *Before(const TObject *obj) const;
TObject *After(const TObject *obj) const;
TObject *First() const;
TObject *Last() const;
void Sort();
Int_t BinarySearch(TObject *obj);
ClassDef(TOrdCollection,0) //An ordered collection
};
//////////////////////////////////////////////////////////////////////////
// //
// TOrdCollectionIter //
// //
// Iterator of ordered collection. //
// //
//////////////////////////////////////////////////////////////////////////
class TOrdCollectionIter : public TIterator,
public std::iterator<std::bidirectional_iterator_tag,
TObject*, std::ptrdiff_t,
const TObject**, const TObject*&> {
private:
const TOrdCollection *fCol; //collection being iterated
Int_t fCurCursor; //current position in collection
Int_t fCursor; //next position in collection
Bool_t fDirection; //iteration direction
TOrdCollectionIter() : fCol(0), fCurCursor(0), fCursor(0), fDirection(kIterForward) { }
public:
TOrdCollectionIter(const TOrdCollection *col, Bool_t dir = kIterForward);
TOrdCollectionIter(const TOrdCollectionIter &iter);
~TOrdCollectionIter() { }
TIterator &operator=(const TIterator &rhs);
TOrdCollectionIter &operator=(const TOrdCollectionIter &rhs);
const TCollection *GetCollection() const { return fCol; }
TObject *Next();
void Reset();
Bool_t operator!=(const TIterator &aIter) const;
Bool_t operator!=(const TOrdCollectionIter &aIter) const;
TObject *operator*() const;
ClassDef(TOrdCollectionIter,0) //Ordered collection iterator
};
//---- inlines -----------------------------------------------------------------
inline Bool_t TOrdCollection::LowWaterMark() const
{
return (fSize < (fCapacity / 4) && fSize > TCollection::kInitCapacity);
}
inline Int_t TOrdCollection::PhysIndex(Int_t idx) const
{ return (idx < fGapStart) ? idx : idx + fGapSize; }
inline Int_t TOrdCollection::LogIndex(Int_t idx) const
{ return (idx < fGapStart) ? idx : idx - fGapSize; }
#endif
|