Xpace
reflist.h
Go to the documentation of this file.
1 
2 /**********************************************************//**
3  **
4  ** @file index/reflist/reflist.h
5  **
6  ** Copyright (C) 2012 Xpace, LLC. All rights reserved
7  **
8  ** www.xpace.net
9  **
10  **************************************************************/
11 
12 
13 #ifndef XPACE_REFLIST_H
14 #define XPACE_REFLIST_H
15 
16 #include <vector>
17 
18 #include "base/types.h"
19 #include "base/sharedimpl.h"
20 
21 namespace Xpace
22 {
23  /// A cursor into a list of references - e.g., a search result
24  /// A single reference is an array of uint64s
25 
27  {
28  public :
30 
31  /// @return the number of references in the list
32  uint64 getCount
33  ()
34  const;
35 
36  /// @return the current cursor position within the list
37  uint64 getPosition
38  ()
39  const;
40 
41  /// move the cursor
42  /// @param distance the distance to move
43  /// @param relative the starting point; true = move from current position, false = move from start
44  /// @return true if move succeeded, false (and do not move) otherwise
45  bool move
46  (int64 distance = 1,
47  bool relative = true);
48 
49  /// @return the first element of the current ref
50  uint64 operator*
51  ()
52  const;
53  /// @return a pointer to the array of uint64s that make up the current ref
54  const uint64* get
55  ()
56  const;
57  /// @param len - fillin for the number of elements in the current ref
58  /// @return a pointer to the array of uint64s that make up the current ref
59  const uint64* get
60  (uint* len)
61  const;
62 
63  /// Interface of the functor passed to forEach(). Create an
64  /// implemention of forEachRef defining an operator().
65  class Sink
66  {
67  public :
68  virtual ~Sink
69  ()
70  {
71  }
72 
73  /// called for each reference in the list
74  /// @param ref the array of uint64s that make up the current ref
75  /// @return true to continue, false to abort
76  virtual bool operator()
77  (const Ref<uint64>& ref)
78  = 0;
79  };
80 
81  /// Enumerate references in the cursor's underlying reference list, starting at
82  /// start (relative to the whole list), calling the callThis functor for each one.
83  /// The cursor itself is unchanged.
84  /// @param call This will be called for each reference in the list
85  /// @param start Call callThis beginning at this ref
86  /// @return true if all references were iterated, false if iteration was aborted
87  bool forEach
88  (Sink* sink,
89  uint64 start = 0)
90  const;
91 
92  /// @return true if past last ref
93  bool operator!
94  ()
95  const;
96 
97  /// this list OR rhs list
98  /// @param rhs the other source list
99  void opOr
100  (RefListCursor* rhs);
101 
102  /// this list AND rhs list
103  /// @param rhs the other source list
104  void opAnd
105  (RefListCursor* rhs);
106 
107  /// AND a vector of ref lists
108  /// @param list the source lists. NB - any of these may be altered
109  /// @return the result, which may be one of the source lists
110  static RefListCursor opAnd
111  (std::vector<RefListCursor>* list);
112 
113  /// count the refs in this list AND rhs list
114  /// @param rhs the other source list
115  /// @return the number of refs
116  uint64 countAnd
117  (const RefListCursor& rhs)
118  const;
119 
120  /// invert a ref list
121  /// @param end the number of refs in the universe; if 0, get from index
122  void opNot
123  (uint64 end = 0);
124 
125  /// Does this reference list have this ref?
126  /// @param ref look for this ref
127  /// @param pos fill-in the position in the list of this ref
128  /// @return true if the list has the ref, false if not
129  bool hasRef
130  (uint64 ref,
131  uint64* pos = 0)
132  const;
133 
134  /// Does this reference list have this ref?
135  /// @param ref look for this ref
136  /// @param pos fill-in the position in the list of this ref
137  /// @return true if the list has the ref, false if not
138  bool hasRef
139  (std::vector<uint64>& ref,
140  uint64* pos = 0)
141  const;
142 
143  /// add a reference to the list
144  /// @param ref add this ref
145  void addRef
146  (uint64 ref);
147  /// @param ref add this ref
148  void addRef
149  (std::vector<uint64>& ref);
150 
151  /// remove a reference from the list
152  /// @param remove this ref (if it exists)
153  void removeRef
154  (uint64 ref);
155  /// @param remove this ref (if it exists)
156  void removeRef
157  (std::vector<uint64> ref);
158 
159  class Factory;
161  };
162 
163 }; // namespace Xpace
164 
165 #endif
166 
A low-level data holder.
Definition: types_c.h:82
unsigned int uint
Definition: types.h:75
uint const Xpace_Char8 size_t len
Definition: table_c.h:180
A low-level const data holder.
Definition: types.h:165
#define DECLARE_IMPL(className)
Definition: sharedimpl.h:305
unsigned long long uint64
Definition: types.h:87
Copyright (C) 2012 Xpace, LLC.
long long int64
Definition: types.h:86
Interface of the functor passed to forEach().
Definition: reflist.h:65
uint uint64 Xpace_Table_Sink * sink
Definition: table_c.h:340
A cursor into a list of references - e.g., a search result A single reference is an array of uint64s...
Definition: reflist.h:26
Xpace project main namespace
Definition: datetime.h:18
static RefListCursor null
Definition: reflist.h:29

current as of Wed Jun 10 2026 12:00:05