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: sequentialids.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 ************************************************************************/
31 #ifndef ARY_SEQUENTIALIDS_HXX
32 #define ARY_SEQUENTIALIDS_HXX
46 /** Implementation of a set of children to an entity in the Autodoc
47 repository. The children are in the sequence of addition.
53 typedef std::vector
<ID
> data_t
;
54 typedef typename
data_t::const_iterator const_iterator
;
57 explicit SequentialIds(
58 std::size_t i_reserve
= 0 );
65 const_iterator
Begin() const;
66 const_iterator
End() const;
67 std::size_t Size() const;
69 template <class IDENTIFY
>
71 IDENTIFY i_find
) const;
72 template <class IDENTIFY
>
73 // Workaround for Solaris8 compiler: return type has to match alphabetically
74 typename
std::vector
<ID
>::const_iterator
76 IDENTIFY i_find
) const;
91 SequentialIds
<ID
>::SequentialIds(std::size_t i_reserve
)
95 aData
.reserve(i_reserve
);
99 SequentialIds
<ID
>::~SequentialIds()
105 SequentialIds
<ID
>::Add(const ID
& i_child
)
107 aData
.push_back(i_child
);
111 inline typename SequentialIds
<ID
>::const_iterator
112 SequentialIds
<ID
>::Begin() const
114 return aData
.begin();
118 inline typename SequentialIds
<ID
>::const_iterator
119 SequentialIds
<ID
>::End() const
126 SequentialIds
<ID
>::Size() const
132 template <class IDENTIFY
>
134 SequentialIds
<ID
>::Find(IDENTIFY i_find
) const
137 ret
= std::find_if(aData
.begin(), aData
.end(), i_find
);
138 csv_assert(ret
!= aData
.end());
143 template <class IDENTIFY
>
144 // Workaround for Solaris8 compiler: return type has to match alphabetically
145 // typename SequentialIds<ID>::const_iterator
146 typename
std::vector
<ID
>::const_iterator
147 SequentialIds
<ID
>::Search(IDENTIFY i_find
) const
149 return std::find_if(aData
.begin(), aData
.end(), i_find
);