Subversion Repositories gelsvn

Rev

Rev 512 | Rev 515 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 512 Rev 513
Line 80... Line 80...
80
 
80
 
81
    template<typename ITEM>
81
    template<typename ITEM>
82
    inline ItemVector<ITEM>::ItemVector() : size_active(0) {}
82
    inline ItemVector<ITEM>::ItemVector() : size_active(0) {}
83
 
83
 
84
    template<typename ITEM>
84
    template<typename ITEM>
85
    inline ItemVector<ITEM>::ItemVector(IndexType _size, ITEM i = ITEM()) : size_active(_size), items(_size, i){}
85
    inline ItemVector<ITEM>::ItemVector(IndexType _size, ITEM i = ITEM()) : size_active(_size), items(_size, i), active_items(_size, true){}
86
 
86
 
87
    template<typename ITEM>
87
    template<typename ITEM>
88
    ITEM& ItemVector<ITEM>::get(IndexType i)
88
    ITEM& ItemVector<ITEM>::get(IndexType i)
89
    {
89
    {
90
        assert(i < items.size());
90
        assert(i < items.size());
Line 122... Line 122...
122
    }
122
    }
123
 
123
 
124
    template<typename ITEM>
124
    template<typename ITEM>
125
    void ItemVector<ITEM>::remove(IndexType i)
125
    void ItemVector<ITEM>::remove(IndexType i)
126
    {
126
    {
127
        if(active_items[i]) 
127
        if(active_items[i]){ 
128
            --size_active;
128
            --size_active;
129
        active_items[i] = false;
129
            active_items[i] = false;
-
 
130
        }
130
    }
131
    }
131
 
132
 
132
    template<typename ITEM>
133
    template<typename ITEM>
133
    void ItemVector<ITEM>::cleanup()
134
    void ItemVector<ITEM>::cleanup()
134
    {
135
    {
Line 177... Line 178...
177
    }
178
    }
178
 
179
 
179
    template<typename ITEM>
180
    template<typename ITEM>
180
    IndexType ItemVector<ITEM>::index_begin(bool skip = true) const
181
    IndexType ItemVector<ITEM>::index_begin(bool skip = true) const
181
    {
182
    {
182
        if(!skip)
-
 
183
            return 0;
-
 
184
        IndexType i = 0;
183
        IndexType i = 0;
-
 
184
 
-
 
185
        if(!skip)
-
 
186
            return i;
-
 
187
        
185
        while(!active_items[i])
188
        while(i < active_items.size() && !active_items[i])
186
            ++i;
189
            ++i;
-
 
190
 
187
        return i;
191
        return i;
188
    }
192
    }
189
 
193
 
190
    template<typename ITEM>
194
    template<typename ITEM>
191
    IndexType ItemVector<ITEM>::index_end() const
195
    IndexType ItemVector<ITEM>::index_end() const
192
    { return items.size(); }
196
    { return items.size(); }
193
 
197
 
194
    template<typename ITEM>
198
    template<typename ITEM>
195
    IndexType ItemVector<ITEM>::index_next(IndexType index, bool skip = true) const
199
    IndexType ItemVector<ITEM>::index_next(IndexType index, bool skip = true) const
196
    {
200
    {
197
        if(index != items.size())
201
        if(index < items.size())
198
            ++index;
202
            ++index;
199
 
203
 
200
        if(skip){
204
        if(!skip)
201
            while(!in_use(index) && index < items.size()){
205
            return index;
-
 
206
 
202
                ++index;
207
        while(index < items.size() && !active_items[index])
203
            }
208
           ++index;
204
        }
209
 
205
        return index;
210
        return index;
206
    }
211
    }
207
 
212
 
208
    template<typename ITEM>
213
    template<typename ITEM>
209
    IndexType ItemVector<ITEM>::index_prev(IndexType index, bool skip = true) const
214
    IndexType ItemVector<ITEM>::index_prev(IndexType index, bool skip = true) const
210
    {
215
    {
211
        if(index > 0)
216
        if(index > 0)
212
            --index;
217
            --index;
213
 
218
 
214
        if(skip){
219
        if(!skip)
215
            while(!in_use(index) && index > 0){
220
            return index;
-
 
221
 
216
                --index;
222
        while(!active_items[index] && index > 0)
217
            }
223
            --index;
218
        }
224
 
219
        return index;
225
        return index;
220
    }
226
    }
221
 
227
 
222
}
228
}
223
 
229