1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bigpointerarray-new.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <tools/solar.h>
35 #include <tools/debug.hxx>
41 /** Base class for container entries
45 friend class BigPtrArray
;
46 BigPtrArray
* pBigPtrArray_
;
50 BigPtrEntry() : pBigPtrArray_(0), pos_(0)
53 virtual ~BigPtrEntry()
61 BigPtrArray
& GetArray() const
63 return *pBigPtrArray_
;
67 typedef BigPtrEntry
* ElementPtr
;
68 typedef BOOL (*FnForEach
)(const ElementPtr
&, void* pArgs
);
70 /** A container abstraction
75 typedef std::deque
<ElementPtr
> Container_t
;
82 /** Return the number of entries inserted
87 /** Insert an Element into the array at a certain
94 [in] the position where to insert the element.
96 @pre (pos >= 0 && pos <= BigPtrArray.Count())
97 @post (((oldCount + 1) == BigPtrArray.Count()) && BigPtrArray[pos] == rElem)
99 void Insert(const ElementPtr
& rElem
, ULONG pos
);
101 /** Remove a specified number of elements starting at a certain position.
104 [in] the position where to start removing elements
107 [in] the number of elements to remove
109 @pre (pos < BigPtrArray.Count() && n <= BigPtrArray.Count())
110 @post ((oldCount - n) == BigPtrArray.Count())
112 void Remove(ULONG pos
, ULONG n
= 1);
114 /** Move an entry from a certain position to another on.
122 void Move(ULONG fromPos
, ULONG toPos
);
124 /** Replace an entry at a certain position
127 [in] the position of the entry
132 @pre pos < BigPtrArray.Count()
133 @post (oldCount == BigPtrArray.Count() && BigPtrArray[pos] == rElem)
135 void Replace(ULONG pos
, const ElementPtr
& rElem
);
137 /** Get the entry at a certain index
140 [in] the position of the entry
142 @pre pos < BigPtrArray.Count()
144 ElementPtr
operator[](ULONG pos
) const;
148 void ForEach(FnForEach fn
, void* pArgs
= NULL
);
152 void ForEach(ULONG fromPos
, ULONG toPos
, FnForEach fn
, void* pArgs
= NULL
);
156 void FixElementIndizes(Container_t::const_iterator begin
, Container_t::const_iterator end
) const;
159 Container_t container_
;