2 * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef KWQ_LIST_IMPL_H
27 #define KWQ_LIST_IMPL_H
32 class KWQListIteratorImpl;
38 KWQListImpl(void (*deleteFunc)(void *));
39 KWQListImpl(const KWQListImpl &impl);
42 bool isEmpty() const { return nodeCount == 0; }
43 uint count() const { return nodeCount; }
44 void clear(bool deleteItems);
45 void sort(int (*compareFunc)(void *a, void *b, void *data), void *data);
49 bool insert(uint n, const void *item);
50 bool remove(bool deleteItem);
51 bool remove(uint n, bool deleteItem);
52 bool remove(const void *item, bool deleteItem, int (*compareFunc)(void *a, void *b, void *data), void *data);
53 bool removeFirst(bool deleteItem);
54 bool removeLast(bool deleteItem);
55 bool removeRef(const void *item, bool deleteItem);
57 void *getFirst() const;
58 void *getLast() const;
59 void *current() const;
67 void append(const void *item);
68 void prepend(const void *item);
70 uint containsRef(const void *item) const;
71 int findRef(const void *item);
73 KWQListImpl &assign(const KWQListImpl &impl, bool deleteItems);
76 KWQListImpl &operator =(const KWQListImpl &impl);
78 void swap(KWQListImpl &impl);
80 void addIterator(KWQListIteratorImpl *iter) const;
81 void removeIterator(KWQListIteratorImpl *iter) const;
87 void (*deleteItem)(void *);
88 mutable KWQListIteratorImpl *iterators;
90 friend class KWQListIteratorImpl;
94 class KWQListIteratorImpl {
96 KWQListIteratorImpl();
97 KWQListIteratorImpl(const KWQListImpl &impl);
98 ~KWQListIteratorImpl();
100 KWQListIteratorImpl(const KWQListIteratorImpl &impl);
101 KWQListIteratorImpl &operator=(const KWQListIteratorImpl &impl);
106 void *current() const;
112 const KWQListImpl *list;
114 KWQListIteratorImpl *next;
115 KWQListIteratorImpl *prev;
117 friend class KWQListImpl;