Branch data Line data Source code
1 : : //- Class: DLIList
2 : : //-
3 : : //- Assumptions: All data are stored contiguously in the array with
4 : : //- empty slots at the end of the array.
5 : : //-
6 : : //- Owner: Darryl Melander
7 : :
8 : : #ifndef DLILIST_HPP
9 : : #define DLILIST_HPP
10 : :
11 : : #include "CubitDefines.h"
12 : : #include <cstring>
13 : : #include <vector>
14 : : #include <set>
15 : : #include <stdexcept>
16 : : #include <algorithm>
17 : :
18 : : #define DLI_COUNT_INCREMENT 8
19 : : #define DLI_COUNT_FACTOR 1.5
20 : : template<class X> class DLIListIterator;
21 : :
22 : :
23 : : // the following empty template acts as a pure virtual declaration so that
24 : : // new classes using DLIList will not be sorted by pointer
25 : : template <class X> struct DLIListSorter
26 : : {
27 : : // bool operator()(const X &a, const X &b) { return a < b; }
28 : : };
29 : :
30 : : // compare templates for intrinsic types
31 : :
32 : : template <> struct DLIListSorter<int>
33 : : {
34 : : bool operator()(const int &a, const int &b) { return a < b; }
35 : : };
36 : :
37 : : template <> struct DLIListSorter<double>
38 : : {
39 : : bool operator()(const double &a, const double &b) { return a < b; }
40 : : };
41 : :
42 : : // compare template for CubitString.
43 : :
44 : : //template <> struct DLIListSorter<CubitString>
45 : : //{
46 : : // bool operator()(const CubitString &a, const CubitString &b) { return a < b; }
47 : : //};
48 : :
49 : : //! A list class, similar to a std::vector<>.
50 : : /*! DLIList is implemented as an array that is grown by a
51 : : specified amount when the list becomes full.
52 : : Most insertions and deletions at any point other than the end
53 : : of the list are handled inefficiently
54 : : since all data from that point to the end is bubbled
55 : : down/up to fill/create the void. Operators {+} and {+=}
56 : : are provided as an efficient means of assigning one list
57 : : to another or appending one list onto another. The list has
58 : : a current position, which is a zero-based index into the
59 : : list. Many of the member functions operate on the current
60 : : item (the item at the current position) or move the current
61 : : position.
62 : : */
63 : :
64 : : // The new Apple libc++ uses a specialization for std::vector<bool> that prevents
65 : : // DLIList<bool> from re-using the std::vector<X>::const_reference typedef blindly.
66 : : // vector_const_reference_type defined below provides a wrapper to consistently use
67 : : // a plain bool type as DLIList<bool>::const_reference.
68 : : template<typename T>
69 : : struct vector_const_reference_type {
70 : : typedef typename std::vector<T>::const_reference type;
71 : : };
72 : :
73 : : template<>
74 : : struct vector_const_reference_type<bool> {
75 : : typedef bool type;
76 : : };
77 : :
78 : : template<class X> class DLIList
79 : : {
80 : : public:
81 : : friend class DLIListIterator<X>;
82 : :
83 : : typedef typename std::vector<X>::reference reference;
84 : : typedef typename vector_const_reference_type<X>::type const_reference;
85 : : typedef typename std::vector<X>::pointer pointer;
86 : : typedef typename std::vector<X>::const_pointer const_pointer;
87 : :
88 : : typedef typename std::vector<X>::const_iterator const_iterator;
89 : : typedef typename std::vector<X>::iterator iterator;
90 : :
91 : : typedef typename std::vector<X>::value_type value_type;
92 : :
93 : : //! Constructor: Create a list, allocating enough storage for \a size elements.
94 : : /*! Although enough space is allocated for \a size elements, the list starts
95 : : out empty (the size() function will return 0). If the requested memory size
96 : : is 0, then storage is not allocated until the first element is added to the list.
97 : : Additional storage space will be allocated if the list grows beyond its
98 : : original size.
99 : : \param size The amount of storage to pre-allocate for this list.
100 : : */
101 : : explicit DLIList (int size = 0);
102 : :
103 : : //! Copy constructor.
104 : : /*! \param from The list to be copied. */
105 : : DLIList(const DLIList<X>& from);
106 : :
107 : : //! Copy constructor for std::vector
108 : : /*! \param from The list to be copied. */
109 : : explicit DLIList(const std::vector<X>& from);
110 : :
111 : : //! Destructor: Free all resources used by this list.
112 : : /*! The list and its storage space are freed. Note that if this is a list
113 : : of pointers, this destructor will \a NOT delete the objects whose pointers
114 : : are stored in the list.
115 : : */
116 : : ~DLIList();
117 : :
118 : : //! return a begin iterator
119 : : iterator begin();
120 : :
121 : : //! return begin iterator
122 : : const_iterator begin() const;
123 : :
124 : : //! return end iterator
125 : : iterator end();
126 : :
127 : : //! return end iterator
128 : : const_iterator end() const;
129 : :
130 : : //! Move the pointer to the next element in the list.
131 : : /*! If pointer reaches the end of the list, wrap around to the beginning */
132 : : void step();
133 : :
134 : : //! Move the pointer \a n positions forward in the list.
135 : : /*! The pointer will wrap around to the beginning of the list if the end
136 : : is reached. If \a n is less than zero, move backward.
137 : : \param n The number of positions to move forward or backward.
138 : : */
139 : : void step(int n);
140 : :
141 : : //! Move the pointer to the previous element in the list.
142 : : /*! If it reaches the beginning of the list, wrap around to the end. */
143 : : void back();
144 : :
145 : : //! Move the pointer \a n positions backward in the list.
146 : : /*! The pointer will wrap around to the end of the list if the beginning
147 : : is reached. If \a n is less than zero, move forward.
148 : : */
149 : : void back(int n);
150 : :
151 : : //! Set the pointer to the beginning of the list.
152 : : void reset();
153 : : //! Set the pointer to the end of the list.
154 : : void last();
155 : :
156 : : //! Delete all elements in the list.
157 : : /*! This function does not release memory already allocated for the list. This
158 : : call is more efficient than creating a new list repeatedly within a loop.
159 : : */
160 : : void clean_out();
161 : :
162 : : //! Reduces the size of the list by \a k.
163 : : /*! No list storage is freed. Items in the array are not changed.
164 : : If the current position is beyond the new end of the list, then the
165 : : current position is moved to the new end of the list.
166 : : */
167 : : void shrink(int k);
168 : :
169 : : //! Returns CUBIT_TRUE if the current position is at the beginning of the list.
170 : : CubitBoolean is_at_beginning() const;
171 : :
172 : : //! Returns CUBIT_TRUE if the current position is at the end of the list.
173 : : CubitBoolean is_at_end() const;
174 : :
175 : : //! Reverse the items in the list.
176 : : void reverse();
177 : :
178 : : //! Create a copy of a list.
179 : : /*! This is the most efficient way to do this.
180 : : \return A reference to this list.*/
181 : : DLIList<X>& operator=(const DLIList<X>& from);
182 : :
183 : : //! Create a DLIList from a std::vector.
184 : : /*! This is the most efficient way to do this.
185 : : \return A reference to this list.*/
186 : : DLIList<X>& operator=(const std::vector<X>& from);
187 : :
188 : : //! Create a copy of the list an iterator was obtained from.
189 : : /*! If \a from_iterator is not associated with a list,
190 : : then this list becomes empty.
191 : : \param from_iterator An iterator to another list.
192 : : \return A reference to this list.
193 : : */
194 : : DLIList<X>& operator=(const DLIListIterator<X>& from_iterator);
195 : :
196 : : //! Append one list to another list.
197 : : /*! This is the most efficient way to append two lists together.
198 : : \param from The list to be appended to this list.
199 : : \return A reference to this list.
200 : : */
201 : : DLIList<X>& operator+=(const DLIList<X>& from);
202 : :
203 : : //! Append a std::vector to a DLIList.
204 : : /*! This is the most efficient way to append two lists together.
205 : : \param from The list to be appended to this list.
206 : : \return A reference to this list.
207 : : */
208 : : DLIList<X>& operator+=(const std::vector<X>& from);
209 : :
210 : : //! Subtract one list from another list.
211 : : /*! Any element in \from which is also found in this list
212 : : will be removed from this list. Element ordered is retained.
213 : : The \a from list is not modified.
214 : : \param from The list to be subtracted from this list.
215 : : \return A reference to this list.*/
216 : : DLIList<X>& operator-=(const DLIList<X>& from);
217 : :
218 : : //! Compare two lists for equality.
219 : : /*! Two lists are considered equal if they have the same contents.
220 : : The elements do not need to be in the same order. If values are
221 : : repeated, they do have to appear an equal number of times in each list.
222 : : \param from The list to compare with this list.
223 : : \return True if the lists are equal, false otherwise.
224 : : */
225 : : int operator==(const DLIList<X>& from);
226 : :
227 : : //! Compare two lists for inequality.
228 : : /*! Two lists are considered equal if they have the same contents.
229 : : The elements do not need to be in the same order. If values are
230 : : repeated, they do have to appear an equal number of times in each list.
231 : : \param from The list to compare with this list.
232 : : \return False if the lists are equal, true otherwise.
233 : : */
234 : : int operator!=(const DLIList<X>& from);
235 : :
236 : : //! Gets a reference to the element with the given index.
237 : : /*! The index is zero-based.
238 : : \param index The index to the desired element.
239 : : \return A reference to the indicated element.
240 : : */
241 : : const_reference operator[](int index) const;
242 : : reference operator[](int index);
243 : :
244 : : //! Gets a reference to the last element in the list.
245 : : reference last_item( void );
246 : : const_reference last_item( void ) const;
247 : :
248 : : //! Merges the contents of another list into this list.
249 : : /*! Each element in \a merge_list is added to this list, but only if
250 : : it does not already appear in this list. The result is a list where
251 : : no value appears twice.
252 : :
253 : : This function runs faster if you know that no value is repeated in the
254 : : \a merge_list. This is indicated with the \a merge_list_unique parameter.
255 : : If \a merge_list_unique is
256 : : \a true, then elements of \merge_list will be checked against the original
257 : : contents of this list, but not against the other elements of \a merge_list.
258 : : If \a merge_list_unique is \a false, then each element will also be checked
259 : : against the other elements of \merge_list.
260 : :
261 : : \param merge_list The list whose elements will be incorporated into this list.
262 : : \param merge_list_unique A flag indicating whether to skip a check for
263 : : uniqueness between elements of \a merge_list.
264 : : */
265 : : void merge_unique(const DLIList<X>& merge_list,
266 : : bool merge_list_unique = false);
267 : :
268 : : //! Merges the contents of a list of a different type into this list.
269 : : /*! This function is like merge_unique(), except that the type of object
270 : : stored by \a merge_list is not the same as this list's type. The type of
271 : : object stored in the other list must be able to be static_cast<> to this
272 : : list's type.
273 : : \param merge_list The list whose elements will be incorporated into this list.
274 : : \param merge_list_unique A flag indicating whether to skip a check for
275 : : uniqueness between elements of \a merge_list.
276 : : \sa merge_unique()
277 : : */
278 : 923 : template<typename Y> inline void casting_merge_unique(const DLIList<Y>& merge_list,
279 : : bool merge_list_unique = false)
280 : : {
281 : : // Save the current index of the merge_list
282 [ + - ][ + - ]: 923 : int old_size = size();
[ # # ][ # # ]
283 : : int i, j, check_index;
284 : :
285 : : X new_item;
286 : :
287 : : // The resulting list will be at least as large as the larger of the two lists.
288 : : // Reserve space so we don't have to reallocate so often. Note that if
289 : : // this list is already bigger than merge_list, the reserve won't
290 : : // make the list shorter.
291 [ + - ][ - + ]: 923 : assert((int)merge_list.size() >= 0); // Assume that the merge list size does not exceed the maximum value for a signed integer
[ + - ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
292 [ + - ][ + - ]: 923 : reserve(merge_list.size());
[ + - ][ + - ]
[ # # ][ # # ]
[ # # ][ # # ]
293 : :
294 [ + - ][ + + ]: 143619 : for ( i = 0; i < (int)merge_list.size(); i++)
[ + - ][ + + ]
[ # # ][ # # ]
[ # # ][ # # ]
295 : : {
296 : : // Get the item from the merge_list and insert it into "this"
297 : : // list if it doesn't already exist there.
298 [ + - ][ + - ]: 142696 : new_item = static_cast<X>(merge_list[i]);
[ # # ][ # # ]
299 [ + + ][ + - ]: 142696 : check_index = merge_list_unique ? old_size : size();
[ + - ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
300 : :
301 : : // Append the new item and then remove it if necessary.
302 [ + - ][ + - ]: 142696 : append(new_item);
[ # # ][ # # ]
303 [ + + ][ - + ]: 6417111 : for ( j = 0; j < check_index; j++ )
[ # # ][ # # ]
304 : : {
305 [ + - ][ + + ]: 6395364 : if ( listArray[j] == new_item )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
306 : : {
307 [ + - ][ + - ]: 120949 : listArray.resize(listArray.size()-1);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
308 : 120949 : break;
309 : : }
310 : : }
311 : : }
312 : 923 : }
313 : :
314 : : //! Remove all elements that are not also in \a merge_list, preserving order.
315 : : /*! This version is O(n^2). If the order of elements in the list does
316 : : not matter, then consider using intersect_undordered(), which is O(n + sort_time).
317 : : \param merge_list The list containing values to keep.
318 : : \sa intersect_unordered(const DLIList<X>& merge_list)
319 : : */
320 : : void intersect(const DLIList<X>& merge_list);
321 : : //! Remove all elements that are not also in \a merge_list, not preserving order.
322 : : /*! This version is O(n + sort_time). If the order of elements in the list
323 : : is significant, then use intersect(), which is O(n^2) but preserves list order.
324 : : \param merge_list The list containing values to keep.
325 : : \sa intersect(const DLIList<X>& merge_list)
326 : : */
327 : : void intersect_unordered(const DLIList<X>& merge_list);
328 : :
329 : : //! Appends the new item to the list, but only if it isn't already in the list.
330 : : /*! In either case, the current position is not changed.
331 : : \return CUBIT_TRUE if the item was added, otherwise CUBIT_FALSE.
332 : : */
333 : : CubitBoolean append_unique(const_reference new_item);
334 : :
335 : : //! Ensure each element of the list only appears once, not preserving order.
336 : : /*! The list is first sorted for speed, so the order of elements may change.
337 : : The current position is set to 0.
338 : : \sa uniquify_ordered()
339 : : */
340 : : void uniquify_unordered();
341 : : void uniquify_unordered_checked();
342 : :
343 : : //! Ensure each element of the list only appears once, preserving order.
344 : : /*! The order of elements is preserved, but at a speed cost compared to
345 : : uniquify_unordered(). The current position is set to 0.
346 : : \sa uniquify_unordered()
347 : : */
348 : : void uniquify_ordered();
349 : :
350 : : //! Removes the current item from the list.
351 : : /*! Remaining items with an index higher than the current item
352 : : are moved up in the list. The current position is set to the next item
353 : : in the list (i.e., the index does not change) unless the removed item was
354 : : the last item in the list, in which case the current position is set to
355 : : the beginning of the list.
356 : : \return The removed item.
357 : : \sa remove(X val)
358 : : \sa remove_all_with_value(X val)
359 : : \sa omit(X val)
360 : : */
361 : : X remove ();
362 : :
363 : : //! Removes the next item with value \a val from the list.
364 : : /*! Only one element is removed from the list, even if the specified
365 : : value occurs multiple times in the list. The list is searched from
366 : : the current position to the end of the list, then from the beginning of
367 : : the list to the current position. The current position continues to
368 : : point at the same element, unless it is the element which was removed,
369 : : in which case the behavior is identical to remove().
370 : : \param val The value of the item to remove.
371 : : \return Whether the item was found and removed.
372 : : \sa remove()
373 : : \sa remove_all_with_value(X val)
374 : : \sa omit(X val)
375 : : */
376 : : bool remove (const_reference val);
377 : :
378 : : //! Remove all instances of a given value from the list.
379 : : /*! This function can be used to remove multiple items efficiently.
380 : : First, change the value of any elements you want to remove to \a val.
381 : : Next, call this function with that same value. This is more efficient
382 : : than removing each element one at a time. After this function call,
383 : : the current position is set to the start of the list.
384 : : \sa remove()
385 : : \sa remove(X val)
386 : : \sa omit(X val)
387 : : */
388 : : void remove_all_with_value(const_reference val);
389 : :
390 : : //! Removes all instances of a value from the list.
391 : : /*! The current position of the list is not changed, unless the
392 : : current item is removed from the list. If the current item is
393 : : removed, then the current position is moved back one item, looping
394 : : to the back of the list if necessary.
395 : : \param val The value to remove from the list.
396 : : \return CUBIT_TRUE if at least one instance the item was removed, CUBIT_FALSE if not.
397 : : \sa remove()
398 : : \sa remove(X val)
399 : : \sa remove_all_with_value(X val)
400 : : */
401 : : CubitBoolean omit (const_reference val);
402 : :
403 : : //! Returns a constant reference to the current item.
404 : : /*! \return A constant reference to the current item. If the list is empty, an exception is thrown.
405 : : */
406 : : const_reference get () const;
407 : : reference get ();
408 : :
409 : : //! Returns the value at next position in the list.
410 : : /*! The current position is not changed. If the current position is at the
411 : : end of the list, the function wraps to the front of the list and returns the
412 : : value of the first item.
413 : : \return The value of the next item. If the list is empty, an exception is thrown.
414 : : */
415 : : X next () const;
416 : :
417 : : //! Returns the value at \a n positions forward in list.
418 : : /*! The current position is not changed. If \a n positions beyond the
419 : : current position would move past the end of the list, the function wraps
420 : : around to the start of the list.
421 : : \param n The number of positions beyond the current position to return.
422 : : \return The value of the item \a n positions beyond the current position.
423 : : If the list is empty, an exception is thrown.
424 : : */
425 : : X next (int n) const;
426 : :
427 : : //! Returns the value at the previous position in list.
428 : : /*! The current position is not changed. If the current position is at the
429 : : beginning of the list, the function wraps to the end of the list and returns the
430 : : value of the last item.
431 : : \return The value of the previous item. If the list is empty, an exception is thrown.
432 : : */
433 : : X prev () const;
434 : :
435 : : //! Returns the value at \a n positions back in list.
436 : : /*! The current position is not changed. If \a n positions before the
437 : : current position would move before the beginning of the list, the function wraps
438 : : around to the end of the list.
439 : : \param n The number of positions behind the current position to return.
440 : : \return The value of the item \a n positions before the current position.
441 : : If the list is empty, an exception is thrown.
442 : : */
443 : : X prev (int n) const;
444 : :
445 : : //! Returns a reference to the current item, then advances the current position by one.
446 : : /*! If the current position is at the end of the list, the function will
447 : : wrap to the beginning of the list.
448 : : \return A reference to the item at the current position, before stepping.
449 : : */
450 : : reference get_and_step ();
451 : :
452 : : //! Returns a reference to the current item, then moves the current position back one.
453 : : /*! If the current position is at the beginning of the list, the function will
454 : : wrap to the end of the list.
455 : : \return A reference to the item at the current position, before stepping back.
456 : : If the list is empty, an exception is thrown.
457 : : */
458 : : reference get_and_back ();
459 : :
460 : : //! Advances the current position by one, then returns a reference to the current item.
461 : : /*! If the current position is at the end of the list, the function will
462 : : wrap to the beginning of the list.
463 : : \return A reference to the item at the current position, after stepping.
464 : : */
465 : : reference step_and_get ();
466 : :
467 : : //! Moves to the next instance of this value, wrapping if necessary.
468 : : /*! \return Returns \a true if the item was found in the list, otherwise returns \a false.
469 : : */
470 : : CubitBoolean move_to(const_reference item);
471 : :
472 : : //! Return \a true if the item is in the list, \a false otherwise.
473 : : /*! \return Returns \a true if the item was found in the list, otherwise returns \a false.
474 : : */
475 : : CubitBoolean is_in_list(const_reference item) const;
476 : :
477 : : //! Returns and removes last value in list.
478 : : /*! \return Returns the last value in the list. If the list is empty, returns X(0).
479 : : */
480 : : X pop();
481 : :
482 : : //! Puts a value on the end of the list.
483 : : /*! The current position is then set to the end of the list.
484 : : \param val The value to place at the end of the list.
485 : : \return The value placed on the end of the list.
486 : : \sa push_back(X val)
487 : : */
488 : : X push(X val);
489 : :
490 : : //! Insert an item into the list, after current item.
491 : : /*! The newly inserted item becomes the current item. This function is
492 : : inefficient due to bubbling.
493 : : \param val The item to insert.
494 : : */
495 : : void insert (X val);
496 : :
497 : : //! Add a value at start of the list.
498 : : /*! The current position is set to the beginning of the list.
499 : : Inefficient due to bubbling.
500 : : \param val The value to place at the start of the list.
501 : : */
502 : : void insert_first(X val);
503 : :
504 : : //! Place an item at the end of the list.
505 : : /*! This is the most efficient way to insert an item to the list.
506 : : The current position is unchanged.
507 : : \param val The value to place at the end of the list.
508 : : */
509 : : void append(const_reference new_item);
510 : :
511 : : //! Remove the current value and put last value in the list in its place.
512 : : /*! If list order isn't important, this is much more efficient than remove().
513 : : \return The value removed from the list, or X(0) if the list was empty.
514 : : */
515 : : X extract();
516 : :
517 : : //! Change the value of the current item.
518 : : /*! Because this function does not actually remove or insert an element,
519 : : it is quite efficient. If the list is empty, the new value will not be
520 : : inserted into the list.
521 : : \return The former value of the current item, or X(0) if the list was empty.
522 : : */
523 : : X change_to(X val);
524 : :
525 : : //! Orders the list elements from lowest to highest.
526 : : /*! The sort order is determined by operator>= for the
527 : : stored element type.
528 : :
529 : : Use reverse after this call if you want to go the
530 : : other direction.
531 : : */
532 : : void sort();
533 : :
534 : : //! A function which determines the relative order of objects.
535 : : /*!
536 : : The SortFunction should return a negative number if \a a should
537 : : be before \a b, a positive number if \a b comes before \a a, and
538 : : zero if they are equal, or relative order doesn't matter.
539 : : \param a The first object in the comparison
540 : : \param b The second object in the comparison
541 : : \sa sort(SortFunction f)
542 : : */
543 : : typedef int (*SortFunction)(X& a, X& b);
544 : :
545 : : //! Orders the list elements from lowest to highest, as defined by a function.
546 : : /*! The sort order is determined by the passed in SortFunction.
547 : :
548 : : Use reverse after this call if you want to go the
549 : : other direction.
550 : : \param f The function which determines the sort order.
551 : : \sa SortFunction
552 : : */
553 : : void sort(SortFunction f);
554 : :
555 : : //! Allocate enough space for at least \a min_size elements.
556 : : /*! If there is already enough space allocated, the function does nothing; this
557 : : function will never reduce the amount of memory allocated to the list.
558 : : \param min_size The minimum number of elements to be prepared to store.
559 : : */
560 : : void reserve(int min_size);
561 : :
562 : : //! Returns the number of items in the list
563 : : /*! \return The number of items current in the list. */
564 : 13162980 : int size() const
565 : 13162980 : { return (int)listArray.size(); }
566 : :
567 : : //! Returns if the list is empty or not.
568 : : /*! \return true or false */
569 : : bool empty() const
570 : : { return listArray.empty(); }
571 : :
572 : : //! Returns current index of the current position
573 : : /*! \return the current position */
574 : 1011 : int get_index()
575 : 1011 : { return index; }
576 : :
577 : : //! Return the index of an item in list, or -1 if the item is not in the list.
578 : : /*! The location of the first instance of \a val is returned as a zero-based
579 : : index from the start of the list. The list is searched starting from the
580 : : current position, wrapping to the front of the list if necessary.
581 : : \param val The value to search for.
582 : : \return The index of the first instance of \a val, or -1 if the value is not found.
583 : : */
584 : : int where_is_item(const_reference val) const;
585 : :
586 : : //! Returns the number of bytes allocated for this list's storage space.
587 : : int memory_use();
588 : :
589 : : //! Copy this list's contents into an array.
590 : : /*! It is assumed that \a other_array is big enough to hold all of this
591 : : list's elements. No check is made to verify this.
592 : : \param other_array The array into which this list's contents will be copied.
593 : : */
594 : : void copy_to(X *other_array);
595 : :
596 : : //! Copy items from an array into this list.
597 : : /*! Any prior contents of this list are removed. The list allocates additional storage if necessary to hold all of
598 : : \a other_array's contents.
599 : : \param other_array The array from which items will be copied.
600 : : \param other_size The number of items to be copied from \a other_array.
601 : : */
602 : : void copy_from(X *other_array, const int other_size);
603 : :
604 : : //! Moves to the nearest instance of \a val, searching both forward and backward.
605 : : /*!
606 : : \return True if an item with the specified value was found, false otherwise.
607 : : */
608 : : CubitBoolean move_to_nearby(const X val);
609 : :
610 : : //! Returns the distance to the nearest element with a given value.
611 : : /*! The returned value is always positive, regardless of whether the
612 : : closest element is before or after the current position.
613 : : \param val The value to search for.
614 : : \return The distance to the closest element with value \a val.
615 : : */
616 : : int distance_to_nearby(const X val);
617 : :
618 : : //! Set the current position to point at one of the two items, where the previous item is the other item.
619 : : /*! This function looks for a place in the list where these two items are adjacent
620 : : to each other, in either order. The current position is then set to the later
621 : : of the two items. The function acts in a wrapped manner, such that the last
622 : : item in the list is considered adjacent to the first item in the list.
623 : : \param val1 One of the values to look for.
624 : : \param val2 The other value to look for.
625 : : \return \a true if the two items are found adjacent to each other, \a false otherwise.
626 : : */
627 : : CubitBoolean move_between(X val1, X val2);
628 : :
629 : : //! Return a std::vector with the same contents as this list.
630 : : /*! This function creates a std::vector from the DLIList and returns it.
631 : : */
632 : : const std::vector<X>& as_vector() const;
633 : :
634 : :
635 : : void swap(std::vector<X>& other);
636 : :
637 : : private:
638 : : void lengthen_list(int by_how_much = DLI_COUNT_INCREMENT,
639 : : double by_what_factor = DLI_COUNT_FACTOR );
640 : : //- Makes the array bigger. Multiply current size
641 : : //- "by_what_factor" and add 'by_how_much'.
642 : :
643 : : int index; // Index of current item in {listArray} (so we should assume that the listArray size does not exceed the maximum value for a signed integer?)
644 : : std::vector<X> listArray;
645 : : };
646 : :
647 : : // *** inline function definitions *******************************************
648 : : template <class X> inline
649 : : DLIList<X>& DLIList<X>::operator=(const DLIListIterator<X>& from_iter)
650 : : {
651 : : if ( from_iter.dlIList )
652 : : *this = *(from_iter.dlIList);
653 : : else
654 : : clean_out();
655 : : return *this;
656 : : }
657 : :
658 : : template <class X> inline
659 : 143972 : typename DLIList<X>::const_reference DLIList<X>::operator[](int indexIn) const
660 : : {
661 [ - + ][ # # ]: 143972 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ # # ][ # # ]
662 [ + - ][ - + ]: 143972 : if(indexIn < 0 || (size_t)indexIn >= listArray.size())
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
663 [ # # ][ # # ]: 0 : throw std::out_of_range("Index out of Bounds\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
664 : 143972 : return listArray[indexIn];
665 : : }
666 : :
667 : : template <class X> inline
668 : 385126 : typename DLIList<X>::reference DLIList<X>::operator[](int indexIn)
669 : : {
670 [ - + ][ - + ]: 385126 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ # # ]
[ - + ][ - + ]
[ # # ][ # # ]
671 [ + - ][ - + ]: 385126 : if(indexIn < 0 || (size_t)indexIn >= listArray.size())
[ - + ][ + - ]
[ - + ][ - + ]
[ + - ][ - + ]
[ - + ][ + - ]
[ - + ][ - + ]
[ + - ][ - + ]
[ - + ][ + - ]
[ - + ][ - + ]
[ + - ][ - + ]
[ - + ][ + - ]
[ - + ][ - + ]
[ + - ][ - + ]
[ - + ][ # # ]
[ # # ][ # # ]
[ + - ][ - + ]
[ - + ][ + - ]
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
672 [ # # ][ # # ]: 0 : throw std::out_of_range("Index out of Bounds\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
673 : 385126 : return listArray[indexIn];
674 : : }
675 : :
676 : : template <class X> inline
677 : 0 : typename DLIList<X>::reference DLIList<X>::last_item(void)
678 : : {
679 [ # # ]: 0 : assert( listArray.size() > 0 );
680 : 0 : return listArray[listArray.size()-1];
681 : : }
682 : :
683 : : template <class X> inline
684 : : typename DLIList<X>::const_reference DLIList<X>::last_item(void) const
685 : : {
686 : : assert( listArray.size() > 0 );
687 : : return listArray[listArray.size()-1];
688 : : }
689 : :
690 : 1113394 : template <class X> inline void DLIList<X>::step()
691 : : {
692 [ + + ][ + - ]: 1113394 : if (!listArray.empty())
[ # # ][ + - ]
[ + - ][ # # ]
[ + - ][ # # ]
[ + - ]
693 : 1112432 : index++;
694 [ - + ][ - + ]: 1113394 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ # # ][ - + ]
[ - + ][ # # ]
[ - + ][ # # ]
[ - + ]
695 [ + + ][ + + ]: 1113394 : if (index >= (int)listArray.size())
[ # # ][ + + ]
[ + + ][ # # ]
[ + + ][ # # ]
[ + - ]
696 : 114678 : index = 0;
697 : 1113394 : }
698 : :
699 : 882234 : template <class X> inline void DLIList<X>::step(int n)
700 : : {
701 : 882234 : const int itemCount = (int)listArray.size();
702 [ - + ][ - + ]: 882234 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
703 [ + - ][ + - ]: 882234 : if (itemCount > 0)
[ + - ][ + - ]
[ # # ][ # # ]
[ # # ][ # # ]
704 : : {
705 : 882234 : index += n;
706 [ - + ][ - + ]: 882234 : if (index < 0)
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
707 : 0 : index = itemCount - (-index) % itemCount;
708 [ - + ][ - + ]: 882234 : if (index >= itemCount)
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
709 : 0 : index %= itemCount;
710 : : }
711 : 882234 : }
712 : :
713 : : // Chop off the last (k) items in the list.
714 : : template <class X> inline void DLIList<X>::shrink(int k)
715 : : {
716 : : if (k > 0)
717 : : {
718 : : const int itemCount = (int)listArray.size();
719 : : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
720 : :
721 : : if (itemCount > k)
722 : : listArray.resize(itemCount - k);
723 : : else
724 : : listArray.clear();
725 : :
726 : : const int itemNewCount = (int)listArray.size();
727 : : if (index >= itemNewCount)
728 : : {
729 : : if (itemNewCount > 0)
730 : : index = itemNewCount - 1;
731 : : else
732 : : index = 0;
733 : : }
734 : : }
735 : : }
736 : :
737 : 22 : template <class X> inline void DLIList<X>::back()
738 : : {
739 : 22 : const int itemCount = (int)listArray.size();
740 [ - + ][ # # ]: 22 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
741 [ + - ][ # # ]: 22 : if (itemCount > 0)
742 : : {
743 : 22 : index--;
744 [ - + ][ # # ]: 22 : if (index < 0)
745 : 0 : index = itemCount - 1;
746 : : }
747 : 22 : }
748 : :
749 : : template <class X> inline void DLIList<X>::back(int n)
750 : : {
751 : : step(-n);
752 : : }
753 : :
754 : 6375506 : template <class X> inline void DLIList<X>::reset()
755 : : {
756 : 6375506 : index = 0;
757 : 6375506 : }
758 : :
759 : 4509101 : template <class X> inline void DLIList<X>::last()
760 : : {
761 : 4509101 : const int itemCount = (int)listArray.size();
762 [ - + ][ - + ]: 4509101 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ # # ][ - + ]
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
763 [ + + ][ + + ]: 4509101 : if (itemCount > 0)
[ + + ][ + - ]
[ + + ][ + + ]
[ + + ][ + - ]
[ + - ][ + - ]
[ # # ][ + - ]
[ + - ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
764 : 4499461 : index = itemCount - 1;
765 : 4509101 : }
766 : :
767 : 0 : template <class X> inline CubitBoolean DLIList<X>::is_at_beginning() const
768 : : {
769 [ # # ]: 0 : if (!index)
770 : 0 : return CUBIT_TRUE;
771 : : else
772 : 0 : return CUBIT_FALSE;
773 : : }
774 : :
775 : 0 : template <class X> inline CubitBoolean DLIList<X>::is_at_end() const
776 : : {
777 : 0 : const int itemCount = (int)listArray.size();
778 [ # # ]: 0 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
779 [ # # ][ # # ]: 0 : if (itemCount == 0 || index == itemCount - 1)
780 : 0 : return CUBIT_TRUE;
781 : : else
782 : 0 : return CUBIT_FALSE;
783 : : }
784 : :
785 : 3191888 : template <class X> inline void DLIList<X>::clean_out()
786 : : {
787 : 3191888 : listArray.clear();
788 : 3191888 : index = 0;
789 : 3191888 : }
790 : :
791 : 89034 : template <class X> inline CubitBoolean DLIList<X>::is_in_list(const_reference item) const
792 : : {
793 [ + + ][ + + ]: 89034 : return where_is_item(item) >= 0 ? CUBIT_TRUE : CUBIT_FALSE;
[ - + ][ - + ]
[ - + ][ + + ]
[ # # ][ + + ]
[ # # ]
794 : : }
795 : :
796 : : //- Add item to end of list, do not change current index value.
797 : : //- This function used to reduce time required to do an insert
798 : : //- followed by a move_to back to where we were.
799 : 15334879 : template <class X> inline void DLIList<X>::append(const_reference new_item)
800 : : {
801 : : // see if the list must be lengthened
802 [ + + ][ + + ]: 15334879 : if (listArray.capacity() == listArray.size())
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + - ][ + + ]
[ + + ][ + + ]
[ # # ][ # # ]
[ # # ][ # # ]
803 : 2876505 : lengthen_list();
804 : :
805 : 15334879 : listArray.push_back(new_item);
806 : 15334879 : }
807 : :
808 : 3381098 : template <class X> inline typename DLIList<X>::reference DLIList<X>::get()
809 : : {
810 [ - + ][ - + ]: 3381098 : if ( listArray.empty() )
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ]
811 : : {
812 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted get of empty DLIList\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
813 : : /*PRINT_WARNING("Attempted get of empty DLIList\n");*/
814 : : }
815 : :
816 : 3381098 : return listArray[index];
817 : : }
818 : :
819 : 649 : template <class X> inline typename DLIList<X>::const_reference DLIList<X>::get() const
820 : : {
821 [ - + ]: 649 : if ( listArray.empty() )
822 : : {
823 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted get of empty DLIList\n");
824 : : /*PRINT_WARNING("Attempted get of empty DLIList\n");*/
825 : : }
826 : 649 : return listArray[index];
827 : : }
828 : :
829 : 9324241 : template <class X> inline typename DLIList<X>::reference DLIList<X>::get_and_step()
830 : : {
831 [ - + ][ - + ]: 9324241 : if ( listArray.empty() )
[ + + ][ - + ]
[ - + ][ - + ]
[ - + ][ + + ]
[ - + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + # ]
[ + # ][ - + ]
[ + # ][ + # ]
[ + # ][ + # ]
[ + # ][ + # ]
[ + # ][ + # ]
[ + # ][ # # ]
[ # # ][ # ]
[ - ][ - ][ - ]
[ - ][ - ][ - ]
[ - ][ # ][ - ]
[ - ][ - ][ - ]
[ - ][ - ][ - ]
[ - ][ - ][ # ]
[ # ][ # ][ # ]
[ - ][ # ][ - ]
[ # ]
832 : : {
833 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted get_and_step from empty DLIList\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
834 : : /*PRINT_WARNING("Attempted get_and_step from empty DLIList\n");*/
835 : : }
836 [ # # ][ + - ]: 9324241 : reference temp = listArray[index++];
[ # # ]
837 [ - + ][ - + ]: 9324241 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ # # ]
[ # # ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ - + ]
[ + - ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ # # ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ - + ][ # # ]
[ - + ][ # # ]
838 [ + + ][ + + ]: 9324241 : if (index == (int)listArray.size())
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + # ]
[ + # ][ + - ]
[ + # ][ + # ]
[ - # ][ + # ]
[ + # ][ + # ]
[ + # ][ - # ]
[ + # ][ # # ]
[ # # ][ # ]
[ + ][ + ][ + ]
[ + ][ + ][ + ]
[ + ][ # ][ + ]
[ + ][ + ][ + ]
[ + ][ + ][ + ]
[ + ][ + ][ # ]
[ # ][ # ][ # ]
[ + ][ # ][ + ]
[ # ]
839 : 3935566 : index = 0;
840 : 9324241 : return temp;
841 : : }
842 : :
843 : 0 : template <class X> inline typename DLIList<X>::reference DLIList<X>::get_and_back ()
844 : : {
845 [ # # ][ # # ]: 0 : if ( listArray.empty() )
[ # # ][ # # ]
846 : : {
847 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted get_and_back from empty DLIList\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
848 : : /*PRINT_WARNING("Attempted get_and_back from empty DLIList\n");*/
849 : : }
850 : 0 : reference temp = listArray[index--];
851 [ # # ][ # # ]: 0 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ # # ][ # # ]
852 [ # # ][ # # ]: 0 : if (index < 0)
[ # # ][ # # ]
853 : 0 : index = (int)listArray.size() - 1;
854 : 0 : return temp;
855 : : }
856 : :
857 : 1914 : template <class X> inline X DLIList<X>::next() const
858 : : {
859 [ - + ][ # # ]: 1914 : if (listArray.empty())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
860 : : {
861 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted next of empty DLIList\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
862 : : /*PRINT_WARNING("Attempted next of empty DLIList\n");*/
863 : : }
864 : : else {
865 [ - + ][ # # ]: 1914 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
866 [ - + ][ # # ]: 1914 : if (index == (int)listArray.size() - 1)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
867 : 0 : return listArray[0];
868 : : else
869 : 1914 : return listArray[index + 1];
870 : : }
871 : : }
872 : :
873 : 311617 : template <class X> inline X DLIList<X>::next(int n) const
874 : : {
875 [ - + ][ - + ]: 311617 : if ( listArray.empty() )
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
876 : : {
877 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted next of empty DLIList\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
878 : : /*PRINT_WARNING("Attempted next of empty DLIList\n");*/
879 : : }
880 : : else
881 : : {
882 : : // return the proper index
883 : : // beware of negative n leading to negative new_index
884 : 311617 : int new_index = index+n;
885 [ - + ][ - + ]: 311617 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
886 [ + + ][ - + ]: 312739 : while (new_index < 0)
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
887 : 1122 : new_index += listArray.size();
888 [ + + ][ - + ]: 311617 : if ((size_t)new_index >= listArray.size())
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
889 : 77 : new_index %= listArray.size();
890 : :
891 : 311617 : return listArray[new_index];
892 : : }
893 : : }
894 : :
895 : 1278 : template <class X> inline X DLIList<X>::prev() const
896 : : {
897 : 1278 : return this->next(-1);
898 : : }
899 : :
900 : 594 : template <class X> inline X DLIList<X>::prev(int n) const
901 : : {
902 : 594 : return this->next(-n);
903 : : }
904 : :
905 : : //- put new item in list at index 0 and make it current
906 : 517 : template <class X> inline void DLIList<X>::insert_first(X new_item)
907 : : {
908 : : // set index to -1 ... index will be set to 0 in insert
909 : 517 : index = -1;
910 : 517 : insert(new_item);
911 : 517 : }
912 : :
913 : 498713 : template <class X> inline CubitBoolean DLIList<X>::move_to (const_reference item)
914 : : {
915 : 498713 : int item_index = where_is_item(item);
916 : 498713 : CubitBoolean rv = CUBIT_FALSE;
917 [ + + + + : 498713 : if (item_index >= 0)
+ - + + -
+ + - + -
+ - # # -
+ ]
918 : : {
919 : 417195 : index = item_index;
920 : 417195 : rv = CUBIT_TRUE;
921 : : }
922 : 498713 : return rv;
923 : : }
924 : :
925 : 78442 : template <class X> inline X DLIList<X>::change_to (X new_value)
926 : : {
927 [ - + ][ - + ]: 78442 : if ( listArray.empty() )
[ - + ][ # # ]
[ # # ][ - + ]
[ # # ][ # # ]
[ - + ]
928 : : {
929 [ # # ][ # # ]: 0 : throw std::out_of_range("DLIList: Attempted update of empty list\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # ][ # ][ # ]
[ # ][ # # ]
[ # # ][ # ]
[ # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
930 : : //PRINT_WARNING("DLIList: Attempted update of empty list\n");
931 : : }
932 : :
933 [ # # ][ + - ]: 78442 : X temp = listArray[index];
934 [ # # + - ]: 78442 : listArray[index] = new_value;
935 : 78442 : return temp;
936 : : }
937 : :
938 : : // Removes every instance of 'val' in list.
939 : : // Set to beginning of list after this call.
940 : 10957 : template <class X> inline void DLIList<X>::remove_all_with_value(const_reference val)
941 : : {
942 : 10957 : size_t j = 0;
943 : 10957 : size_t i = 0;
944 : 10957 : const size_t itemCount = listArray.size();
945 : :
946 [ + + ][ + + ]: 31923 : for ( ; i < itemCount; i++)
[ + + ][ + + ]
[ + + ][ # # ]
[ # # ][ # # ]
[ # # ][ + + ]
947 [ + + ][ - + ]: 20966 : if (listArray[i] != val && j++ != i)
[ - + ][ + + ]
[ + + ][ + + ]
[ + + ][ - + ]
[ - + ][ - + ]
[ # # ][ - + ]
[ + - ][ - + ]
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ + + ]
[ - + ][ - + ]
948 : 594 : listArray[j-1] = listArray[i];
949 : :
950 : 10957 : listArray.resize(j);
951 : 10957 : index = 0;
952 : 10957 : }
953 : :
954 : : // Searches for item and removes the next instance from the list.
955 : : // If the item was found and removed it is returned, else 0 is returned.
956 : 416121 : template <class X> inline bool DLIList<X>::remove (const_reference item)
957 : : {
958 [ + + ][ + + ]: 416121 : if (move_to(item))
[ + - ][ + + ]
[ # # ][ # # ]
959 : : {
960 : 350759 : remove();
961 : 350759 : return true;
962 : : }
963 : 65362 : return false;
964 : : }
965 : :
966 : 3327351 : template <class X> inline int DLIList<X>::where_is_item (const_reference item) const
967 : : {
968 [ + + ][ + + ]: 3327351 : if (listArray.empty())
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ]
969 : 845427 : return -1;
970 : :
971 : 2481924 : const int itemCount = (int)listArray.size();
972 [ - + ][ - + ]: 2481924 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ]
973 : :
974 : : // loop through list searching for item ...
975 : : // if found return index
976 : :
977 : : // Search from current index to end of array
978 : : int i;
979 [ + + ][ + + ]: 12489648 : for (i=index; i < itemCount; i++)
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ]
980 [ + + ][ + + ]: 11524949 : if (listArray[i] == item)
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ - + ][ + ]
981 : 1517225 : return i;
982 : :
983 : : // Now search from beginning of array to index...
984 [ + + ][ + - ]: 6292350 : for (i = 0; i < index && i < itemCount; i++)
[ + + ][ + - ]
[ + + ][ + - ]
[ + + ][ + - ]
[ + + ][ + - ]
[ + + ][ + - ]
[ + + ][ + - ]
[ + + ][ + - ]
[ - + ][ # # ]
[ + + ][ + - ]
[ - + ][ # # ]
[ + + ][ + - ]
[ - + ][ # # ]
985 [ + + ][ + + ]: 5461959 : if (listArray[i] == item)
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ # # ][ - + ]
[ # # ][ + + ]
[ # # ][ # ]
986 : 134308 : return i;
987 : :
988 : : // item is not in array, return -1
989 : 830391 : return -1;
990 : : }
991 : : //- Append this new_item to the list if it doesn't already exist in it.
992 : : //- Make sure the index is unchanged.
993 : 1577533 : template <class X> inline CubitBoolean DLIList<X>::append_unique(const_reference new_item)
994 : : {
995 : : // Append new_item, if it isn't already there.
996 [ + + ][ + - ]: 1577533 : if( where_is_item(new_item) < 0 )
[ + + ][ + + ]
[ + - ][ # # ]
[ # # ]
997 : : {
998 : 1493855 : append (new_item);
999 : 1493855 : return CUBIT_TRUE;
1000 : : }
1001 : 83678 : return CUBIT_FALSE;
1002 : : }
1003 : :
1004 : 0 : template <class X> inline X DLIList<X>::push(X value)
1005 : : {
1006 : : //- swapped last and append; current position is set new end
1007 : 0 : append(value);
1008 : 0 : last();
1009 : 0 : return value;
1010 : : }
1011 : :
1012 : 4178384 : template <class X> inline X DLIList<X>::pop()
1013 : : {
1014 : 4178384 : last();
1015 : 4178384 : return remove();
1016 : : }
1017 : :
1018 : : //- Constructor: Create a list with initial size 0. The list
1019 : : //- will be grown by {increment} each time it is filled. Memory for the
1020 : : //- list is not allocated until the first element is inserted using
1021 : : //- {insertLink}.
1022 : 13481898 : template <class X> inline DLIList<X>::DLIList (int sizeIn)
1023 : : {
1024 : 6740949 : index = 0;
1025 [ + - + - : 6740949 : listArray.reserve(sizeIn);
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
+ - + - +
- + - + -
# # + - #
# # # # #
# # # # ]
1026 : 6740949 : }
1027 : :
1028 : : //- Copy Constructor
1029 : 1349726 : template <class X> inline DLIList<X>::DLIList(const DLIList<X>& from)
1030 : : {
1031 [ + - + - : 674863 : if (&from != this)
+ - + - +
- + - + -
+ - ]
1032 : : {
1033 : 674863 : index = from.index;
1034 [ + - ][ + - ]: 674863 : listArray = from.listArray;
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
1035 : : }
1036 : 674863 : }
1037 : :
1038 : : //- Copy constructor for std::vector
1039 : 22 : template <class X> inline DLIList<X>::DLIList(const std::vector<X>& from)
1040 : : {
1041 : : // Setup the variables
1042 : 11 : index = 0;
1043 [ + - ]: 11 : listArray = from;
1044 : 11 : }
1045 : :
1046 : : // Destructor
1047 : 7328337 : template <class X> inline DLIList<X>::~DLIList()
1048 : : {
1049 : 7328337 : }
1050 : :
1051 : 3013844 : template <class X> inline void DLIList<X>::reserve(int min_size)
1052 : : {
1053 : 3013844 : listArray.reserve(min_size);
1054 : 3013844 : }
1055 : :
1056 : 2876516 : template <class X> inline void DLIList<X>::lengthen_list(int by_how_much,
1057 : : double by_what_factor)
1058 : : {
1059 : : // Make a new array
1060 : 2876516 : int new_size = (int) ((double)listArray.capacity() * by_what_factor) + by_how_much;
1061 [ - + ][ - + ]: 2876516 : assert(new_size > 0);
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
1062 : 2876516 : reserve(new_size);
1063 : 2876516 : }
1064 : :
1065 : : //- put new item in list after current item and make it current
1066 : 517 : template <class X> inline void DLIList<X>::insert(X new_item)
1067 : : {
1068 : : // see if the list must be lengthened
1069 [ + + ][ - + ]: 517 : if ( listArray.size() == listArray.capacity())
1070 : : {
1071 : 11 : lengthen_list();
1072 : : }
1073 : :
1074 : : // set new index
1075 [ + + ][ + - ]: 517 : if ( !listArray.empty() )
1076 : : {
1077 : 506 : index++;
1078 : : }
1079 : : else
1080 : : {
1081 : 11 : index = 0;
1082 : : }
1083 : :
1084 [ + - ][ + - ]: 517 : listArray.insert(listArray.begin()+index, new_item);
[ + - ][ + - ]
[ + - ][ + - ]
1085 : 517 : }
1086 : :
1087 : : //- merge the input list, merge_list, with the current list, making
1088 : : //- sure not to add duplicate items into the current list
1089 : : template <class X> inline
1090 : 791 : void DLIList<X>::merge_unique ( const DLIList<X>& merge_list,
1091 : : bool merge_list_unique )
1092 : : {
1093 : 791 : this->casting_merge_unique(merge_list, merge_list_unique);
1094 : 791 : }
1095 : :
1096 : 0 : template <class X> inline void DLIList<X>::intersect_unordered(
1097 : : const DLIList<X>& merge_list )
1098 : : {
1099 [ # # ][ # # ]: 0 : if ( &merge_list == this )
1100 : 0 : return;
1101 : :
1102 [ # # ][ # # ]: 0 : intersect (merge_list);
1103 : 0 : return;
1104 : :
1105 : : DLIList <X> intersect_list(merge_list); // copy input list so can sort
1106 : : sort();
1107 : : intersect_list.sort();
1108 : :
1109 : : typename std::vector<X>::iterator iter1 = listArray.begin(); // iterator for this array
1110 : : typename std::vector<X>::iterator end1 = listArray.end(); // end of this array
1111 : : typename std::vector<X>::iterator iter2 = intersect_list.listArray.begin(); // iterstor for other array
1112 : : typename std::vector<X>::iterator end2 = intersect_list.listArray.end();// end of other array
1113 : : typename std::vector<X>::iterator insertIt; // location of last insert
1114 : : bool first = true;
1115 : :
1116 : : for ( ; iter1 < end1; ++iter1 )
1117 : : {
1118 : : while (iter2 < end2 && *iter2 < *iter1)
1119 : : ++iter2;
1120 : :
1121 : : if (iter2 == end2)
1122 : : break;
1123 : :
1124 : : // items are the same and ...
1125 : : if (*iter2 == *iter1)
1126 : : {
1127 : : // is the first item or ...
1128 : : if(first)
1129 : : {
1130 : : first = false;
1131 : : insertIt = listArray.begin();
1132 : : *insertIt = *iter1;
1133 : : }
1134 : : // is not the same as the previous item
1135 : : else if(*iter1 != *insertIt)
1136 : : {
1137 : : *++insertIt = *iter1;
1138 : : }
1139 : : }
1140 : : }
1141 : :
1142 : : if(first)
1143 : : {
1144 : : // no intersections
1145 : : listArray.clear();
1146 : : }
1147 : : else
1148 : : {
1149 : : listArray.resize(insertIt - listArray.begin() + 1);
1150 : : }
1151 : : reset();
1152 : : }
1153 : :
1154 : 1004 : template <class X> inline void DLIList<X>::intersect ( const DLIList<X>& merge_list )
1155 : : {
1156 [ - + ][ - + ]: 1004 : if ( &merge_list == this )
[ # # ][ # # ]
[ - + ]
1157 : 1004 : return;
1158 : :
1159 [ + - ][ + - ]: 1004 : const int itemCount = (int)listArray.size();
[ # # ][ # # ]
[ + - ]
1160 [ - + ][ - + ]: 1004 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ # # ][ # # ]
[ - + ]
1161 [ + - ][ + - ]: 1004 : std::vector<X> tmp;
[ # # ][ # # ]
[ + - ]
1162 : :
1163 [ + + ][ + + ]: 3236 : for ( int i=0; i<itemCount; i++ )
[ # # ][ # # ]
[ + + ]
1164 : : {
1165 [ + - ][ + - ]: 2232 : if (merge_list.is_in_list(listArray[i]))
[ + + ][ + - ]
[ + - ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ][ + - ]
[ - + ]
1166 : : {
1167 [ + - ][ + - ]: 44 : tmp.push_back(listArray[i]);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1168 : : }
1169 : : }
1170 : :
1171 [ + - ][ + - ]: 1004 : this->listArray.swap(tmp);
[ # # ][ # # ]
[ + - ]
1172 [ + - ][ + - ]: 1004 : index = 0;
[ # # ][ # # ]
[ + - ]
1173 : : }
1174 : :
1175 : : //template <class X> inline void DLIList<X>::intersect ( void* merge_list )
1176 : : //{
1177 : : // intersect( *(DLIList<X>*)merge_list );
1178 : : //}
1179 : :
1180 : :
1181 : : //- remove the item at the current location and return a pointer to it.
1182 : : //- The next node becomes the current node
1183 : : //- Returns 0 if there are no items in list
1184 : 4585934 : template <class X> inline X DLIList<X>::remove ()
1185 : : {
1186 [ - + ][ - + ]: 4585934 : if ( listArray.empty() )
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1187 : : {
1188 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted link removal from empty DLIList\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1189 : : /*PRINT_WARNING("Attempted link removal from empty DLIList\n");*/
1190 : : }
1191 : :
1192 : : // save the current value
1193 : 4585934 : X temp = listArray[index];
1194 : :
1195 [ + - ][ + - ]: 4585934 : listArray.erase(listArray.begin() + index);
[ + - + - ]
[ + - ]
[ + - + - ]
[ + - ]
[ + - + - ]
[ + - ]
[ + - + - ]
[ + - ]
[ + - + - ]
[ + - ]
[ + - + - ]
[ + - ]
[ + - + - ]
[ + - ]
[ + - # # ]
[ # # ]
[ # # + - ]
[ + - ]
[ + - + - ]
[ + - ][ + - ]
[ # ][ # # ]
[ # # + - ]
[ + - ]
[ + - + - ]
[ + - ]
[ + - # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ][ # # ]
[ # ][ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ + - ][ + - ]
[ + - + - ]
[ + - ]
[ + - + - ]
[ + - ][ + - ]
[ # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ]
[ # # # # ]
[ # # ][ # # ]
1196 [ + + ][ - + ]: 4585934 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ - + ][ - + ]
[ - + ][ - + ]
[ # # ][ - + ]
[ - + ][ - + ]
[ # # ][ # # ]
[ - + ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ - + ][ - + ]
[ - + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1197 [ + + ][ + + ]: 4585934 : if ( index == (int)listArray.size() )
[ + + ][ + + ]
[ + + ][ + + ]
[ + + ][ + + ]
[ + # ][ + - ]
[ + + ][ + ]
[ # ][ # ][ + ]
[ + ][ # ]
[ # + ][ # + ]
[ # + ][ # # ]
[ # # ][ # # ]
[ # # ][ # ]
[ # ][ + ][ + ]
[ + ][ # ][ # ]
[ # ][ # ]
[ # # ]
1198 : : {
1199 : 4467923 : index = 0;
1200 : : }
1201 : :
1202 : 4585934 : return temp;
1203 : : }
1204 : :
1205 : :
1206 : : //- remove the item at the current location and return a pointer to it.
1207 : : //- used for efficiency in cases where preservation of list order is not
1208 : : //- important. moves last list item (itemCount - 1) to current index and
1209 : : //- decrements itemCount. eliminates the need to perform the list bubble
1210 : : //- down (i.e. cut_link) but sacrifices list order in the process. this
1211 : : //- function should not be used when up-stream order from the removed node is
1212 : : //- important. when processing a list using this function the user should
1213 : : //- reset the list to the head (index = 0) before beginning to ensure all
1214 : : //- list nodes are processed properly.
1215 : : //- Returns 0 if there are no items in list
1216 : 11067 : template <class X> inline X DLIList<X>::extract ()
1217 : : {
1218 [ - + ][ # # ]: 11067 : if ( listArray.empty() )
[ # # ][ # # ]
[ # # ][ # # ]
1219 : : {
1220 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted link removal from empty DLIList\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # ][ # ][ # ]
[ # ][ # # ]
[ # # ][ # # ]
[ # # ]
1221 : : /*PRINT_WARNING("Attempted link removal from empty DLIList\n");*/
1222 : : }
1223 : :
1224 : : // save the current value
1225 : 11067 : X temp = listArray[index];
1226 : :
1227 : : // assign last node to the current index
1228 [ # # ][ # # ]: 11067 : listArray[index] = listArray[listArray.size() - 1];
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1229 : :
1230 : : // decrement
1231 [ # # ][ # # ]: 11067 : listArray.resize(listArray.size() - 1);
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1232 [ - + ][ # # ]: 11067 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1233 [ + + ][ + + ]: 11067 : if ( index == (int)listArray.size() && index > 0)
[ + + ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # ]
[ # # ][ # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1234 : : // The choices here are index at beginning or end.
1235 : : // End seems to work better when 'extract' is being used
1236 : : // with calls to 'move_to_item'.
1237 : 1948 : index--;
1238 : :
1239 : 11067 : return temp;
1240 : : }
1241 : :
1242 : : //+//Added so list removals don't disturb current position. PRK 05-23-94
1243 : : //+//Corrected for omitting the last item in the list. PRK 09-16-94
1244 : : //+//Corrected for omitting before the current position. PRK 10-07-94
1245 : : //- Finds instance of item by matching value and delets first instance
1246 : : //- of it from the list. The current position of the list is not changed.
1247 : : //- Returns CUBIT_TRUE if the item was found and deleted, CUBIT_FALSE if not.
1248 : : template <class X> inline CubitBoolean DLIList<X>::omit(const_reference old_val)
1249 : : {
1250 : : int scan_index;
1251 : : int squeeze_index = 0;
1252 : : CubitBoolean found = CUBIT_FALSE;
1253 : : const int itemCount = (int)listArray.size();
1254 : : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
1255 : : for(scan_index = 0; scan_index < itemCount; ++scan_index)
1256 : : {
1257 : : if(listArray[scan_index] == old_val)
1258 : : {
1259 : : found = CUBIT_TRUE;
1260 : : if(index == scan_index)
1261 : : index = squeeze_index - 1;
1262 : : }
1263 : : else
1264 : : {
1265 : : if(scan_index != squeeze_index)
1266 : : {
1267 : : listArray[squeeze_index] = listArray[scan_index];
1268 : : if(index == scan_index) index = squeeze_index;
1269 : : }
1270 : : ++squeeze_index;
1271 : : }
1272 : : }
1273 : :
1274 : : if(found)
1275 : : {
1276 : : listArray.resize(squeeze_index);
1277 : : //+// If the first item was deleted and index pointed to it, make an
1278 : : //+// adjustment here. If itemCount is zero, don't assign -1 again.
1279 : : if(index < 0)
1280 : : index = listArray.empty() ? 0 : listArray.size()-1;
1281 : : }
1282 : :
1283 : : return found;
1284 : : }
1285 : :
1286 : 120896 : template <class X> inline typename DLIList<X>::reference DLIList<X>::step_and_get ()
1287 : : {
1288 [ - + ][ - + ]: 120896 : if ( listArray.empty() )
[ - + ][ - + ]
[ # # ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
1289 : : {
1290 [ # # ][ # # ]: 0 : throw std::out_of_range("Attempted step_and_get from empty DLIList\n");
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
1291 : : /*PRINT_WARNING("Attempted step_and_get from empty DLIList\n");*/
1292 : : }
1293 [ - + ][ - + ]: 120896 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ # # ][ - + ]
[ # # ][ # # ]
[ # # ][ # # ]
1294 [ + + ][ + + ]: 120896 : if (++index == (int)listArray.size())
[ + + ][ + + ]
[ # # ][ + + ]
[ # # ][ # # ]
[ # # ][ # # ]
1295 : 45985 : index = 0;
1296 : 120896 : return listArray[index];
1297 : : }
1298 : :
1299 : 991779 : template <class X> inline DLIList<X>& DLIList<X>::
1300 : : operator=(const DLIList<X>& from)
1301 : : {
1302 [ + - ][ + - ]: 991779 : if (this != &from)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ # # ]
[ + - ][ + - ]
1303 : : {
1304 : 991779 : index = from.index;
1305 : 991779 : listArray = from.listArray;
1306 : : }
1307 : 991779 : return *this;
1308 : : }
1309 : :
1310 : 0 : template <class X> inline DLIList<X>& DLIList<X>::
1311 : : operator=(const std::vector<X>& from)
1312 : : {
1313 : 0 : index = 0;
1314 : 0 : listArray = from;
1315 : 0 : return *this;
1316 : : }
1317 : :
1318 : 679849 : template <class X> inline DLIList<X>& DLIList<X>::
1319 : : operator+=(const DLIList<X>& from)
1320 : : {
1321 : 679849 : listArray.insert(listArray.end(), from.listArray.begin(), from.listArray.end());
1322 : 679849 : return *this;
1323 : : }
1324 : :
1325 : : template <class X> inline DLIList<X>& DLIList<X>::
1326 : : operator+=(const std::vector<X>& from)
1327 : : {
1328 : : listArray.insert(listArray.end(), from.begin(), from.end());
1329 : : return *this;
1330 : : }
1331 : :
1332 : 93 : template <class X> inline DLIList<X>& DLIList<X>::
1333 : : operator-=(const DLIList<X>& from)
1334 : : {
1335 : : // step through items in from list, removing them from this list.
1336 [ - + ][ # # ]: 179 : for (int i = from.listArray.size(); i--; )
[ # # ][ # # ]
[ + + ][ # # ]
[ # # ]
1337 : : {
1338 : : // quit early if this list is empty.
1339 [ # # ][ # # ]: 86 : if (listArray.empty())
[ # # ][ # # ]
[ - + ][ # # ]
[ # # ]
1340 : 0 : break;
1341 : 86 : remove_all_with_value(from.listArray[i]);
1342 : : }
1343 : 93 : return *this;
1344 : : }
1345 : :
1346 : 0 : template <class X> inline int DLIList<X>::operator==(const DLIList<X> &from)
1347 : : {
1348 [ # # ][ # # ]: 0 : if(listArray.size() != from.listArray.size())
[ # # ]
1349 : 0 : return CUBIT_FALSE;
1350 [ # # ]: 0 : DLIList<X> temp_list = from;
1351 [ # # ][ # # ]: 0 : for( size_t i = 0; i < listArray.size(); i++)
1352 [ # # ][ # # ]: 0 : if(temp_list.move_to(listArray[i]))
[ # # ]
1353 [ # # ]: 0 : temp_list.remove();
1354 [ # # ][ # # ]: 0 : return temp_list.listArray.size() == 0;
1355 : : }
1356 : 0 : template <class X> inline int DLIList<X>::operator!=(const DLIList<X> &from)
1357 : : {
1358 : 0 : return !( *this == from );
1359 : : }
1360 : :
1361 : : // Sorts list from low to high value, according to the > operator
1362 : : // of the list type.
1363 : : // List is sorted using a standard Heap Sort algorithm ("Algorithms in C++",
1364 : : // Robert Sedgewick).
1365 : 147 : template <class X> inline void DLIList<X>::sort(typename DLIList<X>::SortFunction f)
1366 : : {
1367 : : // Only sort it if there is more than one
1368 : : // item in the list
1369 : 147 : const int itemCount = (int)listArray.size();
1370 [ - + ][ # # ]: 147 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ - + ]
[ # # ][ # # ]
[ - + ]
1371 [ - + ][ # # ]: 147 : if (itemCount > 1)
[ + - ][ + - ]
[ # # ][ # # ]
[ + - ]
1372 : : {
1373 : :
1374 : : //std::sort(listArray.begin(),listArray.end(),f);
1375 : : //return;
1376 : :
1377 : 136 : int mid = (itemCount >> 1) + 1;
1378 : 136 : int ir = itemCount;
1379 : : X temp_element;
1380 : :
1381 : : // You loop until ir is 1 (ir = iterations remaining)
1382 : : while(CUBIT_TRUE)
1383 : : {
1384 [ # # ][ # # ]: 2021 : if (mid > 1)
[ + + ][ + + ]
[ # # ][ # # ]
[ + + ]
1385 : : {
1386 : 709 : mid--;
1387 [ # # ][ # # ]: 709 : temp_element = listArray[mid - 1];
[ + - ][ + - ]
[ # # ][ # # ]
[ + - ]
1388 : : }
1389 : : else
1390 : : {
1391 : 1312 : ir--;
1392 [ # # ][ # # ]: 1312 : temp_element = listArray[ir];
[ + - ][ + - ]
[ # # ][ # # ]
[ + - ]
1393 [ # # ][ # # ]: 1312 : listArray[ir] = listArray[0];
[ # # ][ # # ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ][ + - ]
1394 [ # # ][ # # ]: 1312 : if (ir == 1)
[ + + ][ + + ]
[ # # ][ # # ]
[ + + ]
1395 : : {
1396 [ # # ][ # # ]: 136 : listArray[0] = temp_element;
[ + - ][ + - ]
[ # # ][ # # ]
[ + - ]
1397 : 283 : return;
1398 : : }
1399 : : }
1400 : :
1401 : 1885 : int i = mid;
1402 : 1885 : int j = mid + mid;
1403 : :
1404 [ # # ][ # # ]: 5449 : while (j <= ir)
[ + + ][ + + ]
[ # # ][ # # ]
[ + + ]
1405 : : {
1406 [ # # ][ # # ]: 3564 : if (j < ir)
[ + + ][ + + ]
[ # # ][ # # ]
[ + + ]
1407 : : {
1408 [ # # ][ # # ]: 2954 : if (f(listArray[j], listArray[j - 1]) >= 0)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + + ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ][ + - ]
[ + - ][ + + ]
1409 : 1434 : j++;
1410 : : }
1411 [ # # ][ # # ]: 3564 : if (f(listArray[j - 1], temp_element) >= 0)
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ][ + - ]
[ + + ][ + - ]
[ + - ][ + + ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ][ + - ]
[ + + ]
1412 : : {
1413 [ # # ][ # # ]: 3307 : listArray[i - 1] = listArray[j - 1];
[ # # ][ # # ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ][ # # ]
[ # # ][ # # ]
[ + - ][ + - ]
1414 : 3307 : i = j;
1415 : 3307 : j += j;
1416 : : }
1417 : : else
1418 : : {
1419 : 257 : j = ir + 1;
1420 : : }
1421 : : }
1422 [ # # ][ # # ]: 1885 : listArray[i - 1] = temp_element;
[ + - ][ + - ]
[ # # ][ # # ]
[ + - ]
1423 : 2021 : }
1424 : : }
1425 : : }
1426 : :
1427 : 1390 : template <class X> inline void DLIList<X>::sort()
1428 : : {
1429 : 1390 : const int itemCount = (int)listArray.size();
1430 [ - + ][ # # ]: 1390 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ # # ]
1431 : : // Only sort it if there is more than one
1432 : : // item in the list
1433 [ + + ][ # # ]: 1390 : if (itemCount > 1)
[ # # ]
1434 : : {
1435 : : //std::sort(listArray.begin(),listArray.end(),DLIListSorter<X>());
1436 : : //return;
1437 : :
1438 : 458 : int mid = (itemCount >> 1) + 1;
1439 : 458 : int ir = itemCount;
1440 [ + - ]: 40 : X temp_element;
1441 : :
1442 : : // You loop until ir is 1 (ir = iterations remaining)
1443 : : while(CUBIT_TRUE)
1444 : : {
1445 [ + + ][ # # ]: 2169 : if (mid > 1)
[ # # ]
1446 : : {
1447 : 851 : mid--;
1448 [ + - ][ + - ]: 851 : temp_element = listArray[mid - 1];
1449 : : }
1450 : : else
1451 : : {
1452 : 1318 : ir--;
1453 [ + - ][ + - ]: 1318 : temp_element = listArray[ir];
1454 [ + - ][ + - ]: 1318 : listArray[ir] = listArray[0];
[ + - ]
1455 [ + + # # ]: 1318 : if (ir == 1)
[ + - ][ # # ]
1456 : : {
1457 [ + - ][ + - ]: 458 : listArray[0] = temp_element;
1458 : 498 : return;
1459 : : }
1460 : : }
1461 : :
1462 : 1711 : int i = mid;
1463 : 1711 : int j = mid + mid;
1464 : :
1465 [ + + ][ # # ]: 4407 : while (j <= ir)
[ # # ]
1466 : : {
1467 [ + + ][ # # ]: 2696 : if (j < ir)
[ # # ]
1468 : : {
1469 [ + + ][ # # ]: 1934 : if (listArray[j] >= listArray[j - 1])
[ # ][ # # ]
[ # # ][ # # ]
[ # # ]
1470 : 962 : j++;
1471 : : }
1472 [ + + ][ + - ]: 2696 : if (listArray[j - 1] >= temp_element)
[ + - # ]
1473 : : {
1474 [ + - ][ + - ]: 2534 : listArray[i - 1] = listArray[j - 1];
[ + - ]
1475 : 2534 : i = j;
1476 : 2534 : j += j;
1477 : : }
1478 : : else
1479 : : {
1480 : 162 : j = ir + 1;
1481 : : }
1482 : : }
1483 [ + - ][ + - ]: 1711 : listArray[i - 1] = temp_element;
1484 [ + - ]: 1711 : }
1485 : : }
1486 : :
1487 : : }
1488 : :
1489 : 159851 : template <class X> inline void DLIList<X>::reverse()
1490 : : {
1491 : 159851 : int front = 0;
1492 [ - + ][ # # ]: 159851 : assert((int)listArray.size() >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ][ # # ]
1493 : 159851 : int tail = (int)listArray.size() - 1;
1494 : : X temp;
1495 : :
1496 [ + + ][ # # ]: 315004 : while (front < tail)
[ + + ][ # # ]
1497 : : {
1498 : 155153 : temp = listArray[front];
1499 : 155153 : listArray[front] = listArray[tail];
1500 : 155153 : listArray[tail] = temp;
1501 : 155153 : tail--;
1502 : 155153 : front++;
1503 : : }
1504 : 159851 : }
1505 : :
1506 : : template <class X> inline int DLIList<X>::memory_use()
1507 : : {
1508 : : // report amount of memory allocated
1509 : :
1510 : : int sizeIn = listArray.capacity() * sizeof(X);
1511 : :
1512 : : // if (verbose_boolean)
1513 : : // {
1514 : : // PRINT_INFO(" DLIList: %d bytes\n",sizeIn);
1515 : : // }
1516 : :
1517 : : return sizeIn;
1518 : : }
1519 : :
1520 : 1928 : template <class X> inline void DLIList<X>::copy_to(X *other_array)
1521 : : //- copy this list's listArray into other_array
1522 : : {
1523 [ - + ][ # # ]: 1928 : if(other_array == 0)
[ - + ]
1524 [ # # ][ # # ]: 0 : throw std::invalid_argument("Array is NULL");
[ # # ][ # # ]
[ # # ][ # # ]
1525 : :
1526 [ + - ][ # # ]: 1928 : if (listArray.size() > 0)
[ + - ]
1527 : : {
1528 : 1928 : const int itemCount = (int)listArray.size();
1529 [ - + ][ # # ]: 1928 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
[ - + ]
1530 [ + + ][ # # ]: 8881 : for (int i = 0; i < itemCount; i++)
[ + + ]
1531 : 6953 : other_array[i] = listArray[i];
1532 : : }
1533 : 1928 : }
1534 : :
1535 : : template <class X> inline void DLIList<X>::copy_from(X *other_array, const int other_size)
1536 : : //- copy other_array into listArray
1537 : : {
1538 : : if(other_array == 0)
1539 : : throw std::invalid_argument("Array is NULL");
1540 : :
1541 : : listArray.clear();
1542 : : listArray.insert(listArray.end(), other_array, other_array+other_size);
1543 : : index = 0;
1544 : : }
1545 : :
1546 : 803 : template <class X> inline CubitBoolean DLIList<X>::move_to_nearby(const X item)
1547 : : {
1548 : : // if (nullItem && (X)nullItem == item)
1549 : : // return CUBIT_FALSE;
1550 : : // else
1551 [ - + ]: 803 : if (listArray.empty())
1552 : 0 : return CUBIT_FALSE;
1553 : : else
1554 : : {
1555 [ + - ]: 803 : const int itemCount = (int)listArray.size();
1556 [ - + ]: 803 : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
1557 [ + - ][ + - ]: 803 : typename std::vector<X>::iterator ptr_up = listArray.begin() + index;
1558 [ + - ][ + + ]: 803 : if (*ptr_up == item)
1559 : 55 : return CUBIT_TRUE;
1560 : :
1561 : : int i_up, i_down;
1562 : 748 : i_up = i_down = index;
1563 : 748 : typename std::vector<X>::iterator ptr_down = ptr_up;
1564 : : while (1)
1565 : : {
1566 : : // check forward in the list increment
1567 [ + + ]: 1012 : if ( ++i_up < itemCount )
1568 [ + - ]: 1001 : ptr_up++;
1569 : : else
1570 : : {
1571 : 11 : i_up = 0;
1572 [ + - ]: 11 : ptr_up = listArray.begin();
1573 : : }
1574 : : // check
1575 [ + - ][ + + ]: 1012 : if ( *ptr_up == item )
1576 : : {
1577 : 143 : index = i_up;
1578 : 143 : return CUBIT_TRUE;
1579 : : }
1580 [ - + ]: 869 : if ( i_up == i_down )
1581 : : {
1582 : 0 : return CUBIT_FALSE;
1583 : : }
1584 : :
1585 : : // check backward in the list
1586 : : // increment
1587 [ + + ]: 869 : if ( --i_down >= 0 )
1588 [ + - ]: 737 : ptr_down--;
1589 : : else
1590 : : {
1591 : 132 : i_down = itemCount-1;
1592 [ + - ][ + - ]: 132 : ptr_down = listArray.begin()+ i_down;
1593 : : }
1594 : : // check
1595 [ + - ][ + + ]: 869 : if ( *ptr_down == item )
1596 : : {
1597 : 605 : index = i_down;
1598 : 605 : return CUBIT_TRUE;
1599 : : }
1600 [ - + ]: 264 : if ( i_up == i_down )
1601 : : {
1602 : 0 : return CUBIT_FALSE;
1603 : : }
1604 : :
1605 : 1067 : }
1606 : : }
1607 : : }
1608 : :
1609 : : template <class X> inline int DLIList<X>::distance_to_nearby(const X body)
1610 : : {
1611 : : // if (nullItem && (X)nullItem == body)
1612 : : // return CUBIT_FALSE;
1613 : : // else
1614 : : {
1615 : : int old_index = index;
1616 : : move_to_nearby( body );
1617 : : int distance = abs(index - old_index);
1618 : : if (distance > listArray.size() / 2)
1619 : : distance = listArray.size() - distance;
1620 : : index = old_index;
1621 : : return distance;
1622 : : }
1623 : : }
1624 : :
1625 : : template <class X> inline CubitBoolean DLIList<X>::move_between(X item1, X item2)
1626 : : {
1627 : : {
1628 : : if ( listArray.empty() )
1629 : : return CUBIT_FALSE;
1630 : :
1631 : : const int itemCount = (int)listArray.size();
1632 : : assert(itemCount >= 0); // Assume that the listArray size does not exceed the maximum value for a signed integer
1633 : :
1634 : : for ( int i = 0; i < itemCount; i++ )
1635 : : {
1636 : : if ( listArray[i] == item1 )
1637 : : {
1638 : : // dance around looking for item2
1639 : : if ( i+1 < itemCount ) {
1640 : : if ( listArray[i+1] == item2 ) {
1641 : : index = i+1;
1642 : : return CUBIT_TRUE;
1643 : : }
1644 : : }
1645 : : if ( i > 0 ) {
1646 : : if ( listArray[i-1] == item2 ) {
1647 : : index = i;
1648 : : return CUBIT_TRUE;
1649 : : }
1650 : : }
1651 : : if ( ( i+1 == itemCount && listArray[0] == item2 )
1652 : : || ( i == 0 && listArray[itemCount-1] == item2 ) )
1653 : : {
1654 : : index = 0;
1655 : : return CUBIT_TRUE;
1656 : : }
1657 : : }
1658 : : }
1659 : : return CUBIT_FALSE;
1660 : : }
1661 : : }
1662 : :
1663 : : // Removes every instance of 'val' in list.
1664 : : // Set to beginning of list after this call.
1665 : 0 : template <class X> inline void DLIList<X>::uniquify_unordered()
1666 : : {
1667 : 0 : const size_t itemCount = listArray.size();
1668 [ # # # # : 0 : if ( itemCount < 2 )
# # ]
1669 : 0 : return;
1670 : :
1671 : 0 : sort();
1672 : :
1673 : 0 : listArray.erase(std::unique(listArray.begin(), listArray.end()), listArray.end());
1674 : :
1675 : 0 : index = 0;
1676 : : }
1677 : : // Removes every instance of 'val' in list.
1678 : : // Set to beginning of list after this call.
1679 : : template <class X> inline void DLIList<X>::uniquify_unordered_checked()
1680 : : {
1681 : : const size_t itemCount = listArray.size();
1682 : : if ( itemCount < 2 )
1683 : : return;
1684 : :
1685 : : sort();
1686 : :
1687 : : size_t j = 1;
1688 : : size_t i = 0;
1689 : :
1690 : : while (j < itemCount)
1691 : : {
1692 : : if (listArray[i] != listArray[j])
1693 : : listArray[++i] = listArray[j++];
1694 : : else
1695 : : j++;
1696 : : }
1697 : :
1698 : : listArray.resize(i + 1);
1699 : : index = 0;
1700 : : }
1701 : :
1702 : 47394 : template <class X> inline void DLIList<X>::uniquify_ordered()
1703 : : {
1704 [ + - ][ + - ]: 47394 : std::set<X> encountered;
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ]
1705 [ + - ][ + - ]: 47394 : typename std::vector<X>::iterator read_iter, write_iter, end_iter = listArray.end();
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ][ # # ]
[ # # ]
1706 : :
1707 : : // To avoid copying the array onto itself in the case
1708 : : // where the list contains no duplicates, loop twice.
1709 : :
1710 : : // Find first duplicate entry.
1711 [ + - ][ + - ]: 344072 : for ( read_iter = listArray.begin(); read_iter != end_iter; ++read_iter )
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ # # ]
[ + - ][ - + ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ + - ][ + + ]
[ # # ][ # # ]
[ # # ][ # # ]
1712 [ + - ][ + - ]: 304857 : if ( ! encountered.insert(*read_iter).second )
[ + + ][ + - ]
[ + - ][ + + ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ - + ]
[ # # ][ # # ]
[ # # ][ + - ]
[ + - ][ - + ]
[ + - ][ + - ]
[ - + ][ + - ]
[ + - ][ - + ]
[ # # ][ # # ]
[ # # ]
1713 : 8179 : break;
1714 : :
1715 : : // Now compact array, removing duplicates. If there
1716 : : // are no duplicates, this loop will not run (read_iter == end_iter).
1717 [ + - ][ + - ]: 316600 : for ( write_iter = read_iter; read_iter != end_iter; ++read_iter )
[ + + ][ + - ]
[ + - ][ + + ]
[ # # ][ + - ]
[ - + ][ # # ]
[ + - ][ - + ]
[ # # ][ + - ]
[ - + ][ # # ]
[ + - ][ - + ]
[ # # ][ + - ]
[ - + ][ # # ]
[ + - ][ - + ]
[ # # ][ # # ]
[ # # ]
1718 [ + - ][ + - ]: 269206 : if ( encountered.insert(*read_iter).second )
[ + + ][ + - ]
[ + - ][ + + ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1719 [ + - ][ + - ]: 72427 : *(write_iter++) = *read_iter;
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1720 : :
1721 [ + - ][ + - ]: 47394 : listArray.resize(write_iter - listArray.begin());
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ][ # # ]
[ # # ]
1722 [ + - ][ + - ]: 47394 : index = 0;
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ # # ]
1723 : 47394 : }
1724 : :
1725 : 400 : template <class X> inline const std::vector<X>& DLIList<X>::as_vector() const
1726 : : {
1727 : 400 : return listArray;
1728 : : }
1729 : :
1730 : : template <class X> class DLIListIterator
1731 : : {
1732 : : friend class DLIList<X>;
1733 : : public:
1734 : : // constructor
1735 : : DLIListIterator() :
1736 : : mIndex(0),
1737 : : dlIList(NULL)
1738 : : {}
1739 : :
1740 : : // destructor
1741 : : virtual ~DLIListIterator()
1742 : : {}
1743 : :
1744 : : void watch( const DLIList <X> *dl_i_list )
1745 : : {
1746 : : dlIList = dl_i_list;
1747 : : mIndex = dlIList->index;
1748 : : }
1749 : :
1750 : : void reset()
1751 : : { mIndex = 0; }
1752 : :
1753 : : void step( int n = 1 )
1754 : : {
1755 : : if (!size())
1756 : : mIndex = 0;
1757 : : else
1758 : : {
1759 : : mIndex += n;
1760 : : while (mIndex < 0)
1761 : : mIndex += dlIList->size();
1762 : : mIndex %= dlIList->size();
1763 : : }
1764 : : }
1765 : :
1766 : : int size() const
1767 : : { return dlIList ? dlIList->size() : 0; }
1768 : :
1769 : : X get() const
1770 : : { return next(0); }
1771 : : X next( int n = 1 ) const;
1772 : : X get_and_step( int n = 1 )
1773 : : {
1774 : : X temp = get();
1775 : : step( n );
1776 : : return temp;
1777 : : }
1778 : :
1779 : : //- Moves to the next instance of this value, wrapping if necessary
1780 : : CubitBoolean move_to(X item)
1781 : : {
1782 : : mIndex = where_is_item( item );
1783 : : return mIndex >= 0 ? CUBIT_TRUE : CUBIT_FALSE;
1784 : : }
1785 : :
1786 : : //- Return True if item is in the list, false otherwise.
1787 : : CubitBoolean is_in_list(X item) const
1788 : : { return where_is_item(item) >= 0 ? CUBIT_TRUE : CUBIT_FALSE; }
1789 : :
1790 : : // Returns CUBIT_TRUE if we're pointing at the last item in the list.
1791 : : CubitBoolean is_at_end() const
1792 : : {
1793 : : if (size() == 0 || mIndex == size() - 1)
1794 : : return CUBIT_TRUE;
1795 : : return CUBIT_FALSE;
1796 : : }
1797 : :
1798 : : //- returns CUBIT_TRUE if we're pointing at the first item in the list.
1799 : : CubitBoolean is_at_beginning() const
1800 : : {
1801 : : if (!mIndex || mIndex == size())
1802 : : return CUBIT_TRUE;
1803 : : return CUBIT_FALSE;
1804 : : }
1805 : :
1806 : : protected:
1807 : : // utility functions
1808 : : int where_is_item( X item ) const
1809 : : { return dlIList ? dlIList->where_is_item( item ) : -1; }
1810 : :
1811 : : // data
1812 : : int mIndex;
1813 : : const DLIList<X> *dlIList;
1814 : : };
1815 : :
1816 : : template <class X>
1817 : : inline X DLIListIterator<X>::next( int n ) const
1818 : : {
1819 : : int size_loc = size();
1820 : : if ( size_loc == 0 )
1821 : : return NULL;
1822 : : int index_loc = mIndex + n;
1823 : : while ( index_loc < 0 )
1824 : : index_loc += size_loc;
1825 : : while ( index_loc >= size_loc )
1826 : : index_loc -= size_loc;
1827 : :
1828 : : // if dlIList == NULL, then size == 0 and returned already
1829 : : return dlIList->listArray[index_loc];
1830 : : }
1831 : :
1832 : : template <class X>
1833 : 0 : inline typename DLIList<X>::iterator DLIList<X>::begin()
1834 : : {
1835 : 0 : return this->listArray.begin();
1836 : : }
1837 : :
1838 : : template <class X>
1839 : : inline typename DLIList<X>::const_iterator DLIList<X>::begin() const
1840 : : {
1841 : : return this->listArray.begin();
1842 : : }
1843 : :
1844 : : template <class X>
1845 : 0 : inline typename DLIList<X>::iterator DLIList<X>::end()
1846 : : {
1847 : 0 : return this->listArray.end();
1848 : : }
1849 : :
1850 : : template <class X>
1851 : : inline typename DLIList<X>::const_iterator DLIList<X>::end() const
1852 : : {
1853 : : return this->listArray.end();
1854 : : }
1855 : :
1856 : : template <class X> inline void DLIList<X>::swap(std::vector<X>& other)
1857 : : {
1858 : : this->listArray.swap(other);
1859 : : }
1860 : :
1861 : :
1862 : : #endif //- DLILIST_HPP
1863 : :
|