1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru**********************************************************************
3b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho*   Copyright (C) 1999-2011, International Business Machines
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Corporation and others.  All Rights Reserved.
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru**********************************************************************
6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   Date        Name        Description
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*   10/22/99    alan        Creation.  This is an internal header.
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*                           It should not be exported.
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru**********************************************************************
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/
11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef UVECTOR_H
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define UVECTOR_H
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h"
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uobject.h"
17b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho#include "uarrsort.h"
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "uhash.h"
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * A token comparison function.
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param tok1 A token (object or integer)
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param tok2 A token (object or integer)
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return 0 if the two tokens are equal, -1 if tok1 is < tok2, or
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * +1 if tok1 is > tok2.
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef int8_t U_CALLCONV USortComparator(UHashTok tok1,
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                          UHashTok tok2);
31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * A token assignment function.  It may copy an integer, copy
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a pointer, or clone a pointer, as appropriate.
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dst The token to be assigned to
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param src The token to assign from
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querutypedef void U_CALLCONV UTokenAssigner(UHashTok *dst,
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                                       UHashTok *src);
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Ultralightweight C++ implementation of a <tt>void*</tt> vector
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that is (mostly) compatible with java.util.Vector.
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>This is a very simple implementation, written to satisfy an
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * immediate porting need.  As such, it is not completely fleshed out,
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and it aims for simplicity and conformity.  Nonetheless, it serves
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * its purpose (porting code from java that uses java.util.Vector)
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * well, and it could be easily made into a more robust vector class.
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>Design notes</b>
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>There is index bounds checking, but little is done about it.  If
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * indices are out of bounds, either nothing happens, or zero is
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returned.  We <em>do</em> avoid indexing off into the weeds.
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>There is detection of out of memory, but the handling is very
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * coarse-grained -- similar to UnicodeString's protocol, but even
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * coarser.  The class contains <em>one static flag</em> that is set
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * when any call to <tt>new</tt> returns zero.  This allows the caller
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to use several vectors and make just one check at the end to see if
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a memory failure occurred.  This is more efficient than making a
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * check after each call on each vector when doing many operations on
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * multiple vectors.  The single static flag works best when memory
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * failures are infrequent, and when recovery options are limited or
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * nonexistent.
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Since we don't have garbage collection, UVector was given the
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * option to <em>own</em>its contents.  To employ this, set a deleter
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * function.  The deleter is called on a void* pointer when that
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * pointer is released by the vector, either when the vector itself is
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * destructed, or when a call to setElementAt() overwrites an element,
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * or when a call to remove() or one of its variants explicitly
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * removes an element.  If no deleter is set, or the deleter is set to
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * zero, then it is assumed that the caller will delete elements as
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * needed.
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>In order to implement methods such as contains() and indexOf(),
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UVector needs a way to compare objects for equality.  To do so, it
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * uses a comparison frunction, or "comparer."  If the comparer is not
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * set, or is set to zero, then all such methods will act as if the
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * vector contains no element.  That is, indexOf() will always return
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * -1, contains() will always return FALSE, etc.
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>To do</b>
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Improve the handling of index out of bounds errors.
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @author Alan Liu
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_COMMON_API UVector : public UObject {
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // NOTE: UVector uses the UHashKey (union of void* and int32_t) as
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // its basic storage type.  It uses UKeyComparator as its
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // comparison function.  It uses UObjectDeleter as its deleter
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // function.  These are named for hashtables, but used here as-is
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // rather than duplicating the type.  This allows sharing of
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // support functions.
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t count;
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t capacity;
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UHashTok* elements;
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UObjectDeleter *deleter;
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UKeyComparator *comparer;
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UVector(UErrorCode &status);
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UVector(int32_t initialCapacity, UErrorCode &status);
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UVector(UObjectDeleter *d, UKeyComparator *c, UErrorCode &status);
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UVector(UObjectDeleter *d, UKeyComparator *c, int32_t initialCapacity, UErrorCode &status);
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~UVector();
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Assign this object to another (make this a copy of 'other').
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Use the 'assign' function to assign each element.
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void assign(const UVector& other, UTokenAssigner *assign, UErrorCode &ec);
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Compare this vector with another.  They will be considered
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * equal if they are of the same size and all elements are equal,
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * as compared using this object's comparer.
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool operator==(const UVector& other);
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Equivalent to !operator==()
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    inline UBool operator!=(const UVector& other);
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    //------------------------------------------------------------
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // java.util.Vector API
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    //------------------------------------------------------------
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void addElement(void* obj, UErrorCode &status);
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void addElement(int32_t elem, UErrorCode &status);
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void setElementAt(void* obj, int32_t index);
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void setElementAt(int32_t elem, int32_t index);
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void insertElementAt(void* obj, int32_t index, UErrorCode &status);
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void insertElementAt(int32_t elem, int32_t index, UErrorCode &status);
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void* elementAt(int32_t index) const;
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t elementAti(int32_t index) const;
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool equals(const UVector &other) const;
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void* firstElement(void) const;
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void* lastElement(void) const;
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t lastElementi(void) const;
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t indexOf(void* obj, int32_t startIndex = 0) const;
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t indexOf(int32_t obj, int32_t startIndex = 0) const;
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool contains(void* obj) const;
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool contains(int32_t obj) const;
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool containsAll(const UVector& other) const;
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool removeAll(const UVector& other);
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool retainAll(const UVector& other);
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void removeElementAt(int32_t index);
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool removeElement(void* obj);
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void removeAllElements();
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t size(void) const;
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool isEmpty(void) const;
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool ensureCapacity(int32_t minimumCapacity, UErrorCode &status);
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Change the size of this vector as follows: If newSize is
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * smaller, then truncate the array, possibly deleting held
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * elements for i >= newSize.  If newSize is larger, grow the
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * array, filling in new slots with NULL.
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
19985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    void setSize(int32_t newSize, UErrorCode &status);
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Fill in the given array with all elements of this vector.
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void** toArray(void** result) const;
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    //------------------------------------------------------------
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // New API
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    //------------------------------------------------------------
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UObjectDeleter *setDeleter(UObjectDeleter *d);
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UKeyComparator *setComparer(UKeyComparator *c);
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void* operator[](int32_t index) const;
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Removes the element at the given index from this vector and
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * transfer ownership of it to the caller.  After this call, the
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * caller owns the result and must delete it and the vector entry
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * at 'index' is removed, shifting all subsequent entries back by
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * one index and shortening the size of the vector by one.  If the
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * index is out of range or if there is no item at the given index
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * then 0 is returned and the vector is unchanged.
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void* orphanElementAt(int32_t index);
226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Returns true if this vector contains none of the elements
229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * of the given vector.
230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @param other vector to be checked for containment
231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * @return true if the test condition is met
232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool containsNone(const UVector& other) const;
234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Insert the given object into this vector at its sorted position
237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * as defined by 'compare'.  The current elements are assumed to
238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * be sorted already.
239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void sortedInsert(void* obj, USortComparator *compare, UErrorCode& ec);
241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * Insert the given integer into this vector at its sorted position
244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * as defined by 'compare'.  The current elements are assumed to
245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * be sorted already.
246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void sortedInsert(int32_t obj, USortComparator *compare, UErrorCode& ec);
248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
25085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho     * Sort the contents of the vector, assuming that the contents of the
25185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho     * vector are of type int32_t.
25285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho     */
25385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    void sorti(UErrorCode &ec);
25485bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
25585bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    /**
25685bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho      * Sort the contents of this vector, using a caller-supplied function
25785bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho      * to do the comparisons.  (It's confusing that
25885bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho      *  UVector's USortComparator function is different from the
25985bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho      *  UComparator function type defined in uarrsort.h)
26085bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho      */
26185bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    void sort(USortComparator *compare, UErrorCode &ec);
26285bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho
26385bf2e2fbc60a9f938064abc8127d61da7d19882Claire Ho    /**
264b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * Sort the contents of this vector using a caller-supplied function
265b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * of type UComparator to do the comparison.  Provides more flexibility
266b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * than uvector::sort() because an additional user-parameter can be passed to
267b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     * the comparison function.
268b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho     */
269b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    void sortWithUComparator(UComparator *compare, const void *context, UErrorCode &ec);
270b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
271b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho    /**
272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for this class.
273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static UClassID U_EXPORT2 getStaticClassID();
275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
277ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for the actual class.
278ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
279ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UClassID getDynamicClassID() const;
280ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
281ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
282ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void _init(int32_t initialCapacity, UErrorCode &status);
283ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
284ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t indexOf(UHashTok key, int32_t startIndex = 0, int8_t hint = 0) const;
285ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
286ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void sortedInsert(UHashTok tok, USortComparator *compare, UErrorCode& ec);
287ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
288ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // Disallow
289ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UVector(const UVector&);
290ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
291ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // Disallow
292ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UVector& operator=(const UVector&);
293ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
294ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
295ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
296ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
297ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
298ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Ultralightweight C++ implementation of a <tt>void*</tt> stack
299ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * that is (mostly) compatible with java.util.Stack.  As in java, this
300ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is merely a paper thin layer around UVector.  See the UVector
301ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * documentation for further information.
302ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
303ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p><b>Design notes</b>
304ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
305ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The element at index <tt>n-1</tt> is (of course) the top of the
306ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * stack.
307ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
308ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The poorly named <tt>empty()</tt> method doesn't empty the
309ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * stack; it determines if the stack is empty.
310ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
311ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @author Alan Liu
312ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
313ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_COMMON_API UStack : public UVector {
314ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic:
315ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UStack(UErrorCode &status);
316ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
317ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UStack(int32_t initialCapacity, UErrorCode &status);
318ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
319ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UStack(UObjectDeleter *d, UKeyComparator *c, UErrorCode &status);
320ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
321ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UStack(UObjectDeleter *d, UKeyComparator *c, int32_t initialCapacity, UErrorCode &status);
322ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
323ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual ~UStack();
324ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
325ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // It's okay not to have a virtual destructor (in UVector)
326ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // because UStack has no special cleanup to do.
327ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
328ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UBool empty(void) const;
329ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
330ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void* peek(void) const;
331ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
332ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t peeki(void) const;
333ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
334ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void* pop(void);
335ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
336ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t popi(void);
337ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
338ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    void* push(void* obj, UErrorCode &status);
339ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
340ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t push(int32_t i, UErrorCode &status);
341ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
342ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /*
343ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    If the object o occurs as an item in this stack,
344ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    this method returns the 1-based distance from the top of the stack.
345ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    */
346ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    int32_t search(void* obj) const;
347ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
348ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
349ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for this class.
350ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
351ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    static UClassID U_EXPORT2 getStaticClassID();
352ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
353ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    /**
354ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     * ICU "poor man's RTTI", returns a UClassID for the actual class.
355ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru     */
356ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    virtual UClassID getDynamicClassID() const;
357ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
358ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprivate:
359ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // Disallow
360ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UStack(const UStack&);
361ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
362ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    // Disallow
363ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    UStack& operator=(const UStack&);
364ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru};
365ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
366ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
367ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// UVector inlines
368ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
369ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t UVector::size(void) const {
370ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return count;
371ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
372ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
373ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline UBool UVector::isEmpty(void) const {
374ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return count == 0;
375ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
376ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
377ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline UBool UVector::contains(void* obj) const {
378ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return indexOf(obj) >= 0;
379ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
380ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
381ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline UBool UVector::contains(int32_t obj) const {
382ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return indexOf(obj) >= 0;
383ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
384ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
385ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline void* UVector::firstElement(void) const {
386ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return elementAt(0);
387ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
388ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
389ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline void* UVector::lastElement(void) const {
390ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return elementAt(count-1);
391ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
392ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
393ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t UVector::lastElementi(void) const {
394ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return elementAti(count-1);
395ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
396ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
397ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline void* UVector::operator[](int32_t index) const {
398ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return elementAt(index);
399ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
400ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
401ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline UBool UVector::operator!=(const UVector& other) {
402ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return !operator==(other);
403ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
404ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
405ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru// UStack inlines
406ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
407ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline UBool UStack::empty(void) const {
408ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return isEmpty();
409ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
410ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
411ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline void* UStack::peek(void) const {
412ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return lastElement();
413ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
414ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
415ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t UStack::peeki(void) const {
416ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return lastElementi();
417ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
418ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
419ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline void* UStack::push(void* obj, UErrorCode &status) {
420ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addElement(obj, status);
421ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return obj;
422ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
423ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
424ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruinline int32_t UStack::push(int32_t i, UErrorCode &status) {
425ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    addElement(i, status);
426ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru    return i;
427ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}
428ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
429ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END
430ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
431ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
432