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 DeprecatedPtrListImpl_h
27 #define DeprecatedPtrListImpl_h
31 class DeprecatedListNode
;
32 class DeprecatedPtrListImplIterator
;
34 class DeprecatedPtrListImpl
38 DeprecatedPtrListImpl(void (*deleteFunc
)(void *));
39 DeprecatedPtrListImpl(const DeprecatedPtrListImpl
&impl
);
40 ~DeprecatedPtrListImpl();
42 bool isEmpty() const { return nodeCount
== 0; }
43 unsigned count() const { return nodeCount
; }
44 void clear(bool deleteItems
);
48 bool insert(unsigned n
, const void *item
);
49 bool remove(bool deleteItem
);
50 bool remove(unsigned n
, bool deleteItem
);
51 bool removeFirst(bool deleteItem
);
52 bool removeLast(bool deleteItem
);
53 bool removeRef(const void *item
, bool deleteItem
);
55 void *getFirst() const;
56 void *getLast() const;
57 void *getNext() const;
58 void *getPrev() const;
59 void *current() const;
64 void *take(unsigned n
);
67 void append(const void *item
);
68 void prepend(const void *item
);
70 unsigned containsRef(const void *item
) const;
71 int findRef(const void *item
);
73 DeprecatedPtrListImpl
&assign(const DeprecatedPtrListImpl
&impl
, bool deleteItems
);
76 DeprecatedPtrListImpl
&operator =(const DeprecatedPtrListImpl
&impl
);
78 void swap(DeprecatedPtrListImpl
&impl
);
80 void addIterator(DeprecatedPtrListImplIterator
*iter
) const;
81 void removeIterator(DeprecatedPtrListImplIterator
*iter
) const;
83 DeprecatedListNode
*head
;
84 DeprecatedListNode
*tail
;
85 DeprecatedListNode
*cur
;
87 void (*deleteItem
)(void *);
88 mutable DeprecatedPtrListImplIterator
*iterators
;
90 friend class DeprecatedPtrListImplIterator
;
94 class DeprecatedPtrListImplIterator
{
96 DeprecatedPtrListImplIterator();
97 DeprecatedPtrListImplIterator(const DeprecatedPtrListImpl
&impl
);
98 ~DeprecatedPtrListImplIterator();
100 DeprecatedPtrListImplIterator(const DeprecatedPtrListImplIterator
&impl
);
101 DeprecatedPtrListImplIterator
&operator=(const DeprecatedPtrListImplIterator
&impl
);
103 unsigned count() const;
106 void *current() const;
112 const DeprecatedPtrListImpl
*list
;
113 DeprecatedListNode
*node
;
114 DeprecatedPtrListImplIterator
*next
;
115 DeprecatedPtrListImplIterator
*prev
;
117 friend class DeprecatedPtrListImpl
;