SheafSystem  0.0.0.0
index_iterator.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for class index_iterator
19 
20 #ifndef INDEX_ITERATOR_H
21 #define INDEX_ITERATOR_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef SCOPED_INDEX_H
28 #include "SheafSystem/scoped_index.h"
29 #endif
30 
31 namespace sheaf
32 {
33 
34 class zn_to_bool;
35 
39 class SHEAF_DLL_SPEC index_iterator
40 {
41 
42 public:
43 
48 
53  index_iterator(const zn_to_bool* xhost, const index_space_handle& xid_space, bool xdelete_host = false);
54 
59  virtual ~index_iterator();
60 
64  const zn_to_bool* host() const;
65 
69  int item();
70 
74  const scoped_index& index() const;
75 
79  bool is_done() const;
80 
84  bool is_last() const;
85 
89  void next();
90 
94  void reset();
95 
99  virtual void reset(const zn_to_bool* xhost, const index_space_handle& xid_space, bool xdelete_host = false);
100 
101 protected:
102 
107 
112 
117 
121  int _word_ub;
122 
126  unsigned int _word;
127 
132 
136  int _bit_ub;
137 
141  int _item;
142 
147 
151  int _item_ub;
152 
156  void find_next_item();
157 
162 };
163 
164 } // namespace sheaf
165 
166 #endif // ifndef INDEX_ITERATOR_H
An abstract handle to a space of alternate integer identifiers (aliases) for a subset of a hub set of...
int _word_ub
The upper bound for the word index.
scoped_index _index
The current index in the iteration.
A map from Zn (the integers mod n) to bools. A characteristic function used to represent subsets of Z...
Definition: zn_to_bool.h:52
int _item_ub
The upper bound in item.
unsigned int _word
The current word.
bool _delete_host
True if _host should be deleted when this is deleted.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
int _bit_ub
The upper bound on the bit index.
const zn_to_bool * _host
The subset this is iterating over.
int _item
The current item in the iteration.
Iterates over the subset of Zn defined by the characteristic function host().
int _bit_index
The index of the current bit.
Namespace for the sheaves component of the sheaf system.
int _next_item
The next item in the iteration.
int _word_index
The index of the word containing the current bit.