~ubuntu-branches/ubuntu/gutsy/icu/gutsy

« back to all changes in this revision

Viewing changes to source/common/uvector.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2005-05-21 22:44:31 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: package-import@ubuntu.com-20050521224431-r7rktfhnu1n4tf1g
Tags: 2.1-2.1
Rename icu-doc to icu21-doc. icu-doc is built by the icu28 package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
}
57
57
 
58
58
void UVector::_init(int32_t initialCapacity, UErrorCode &status) {
 
59
    // Fix bogus initialCapacity values; avoid malloc(0)
 
60
    if (initialCapacity < 1) {
 
61
        initialCapacity = DEFUALT_CAPACITY;
 
62
    }
59
63
    elements = (UHashTok *)uprv_malloc(sizeof(UHashTok)*initialCapacity);
60
64
    if (elements == 0) {
61
65
        status = U_MEMORY_ALLOCATION_ERROR;
162
166
    return -1;
163
167
}
164
168
 
 
169
int32_t UVector::indexOf(int32_t obj, int32_t startIndex) const {
 
170
    if (comparer != 0) {
 
171
        UHashTok key;
 
172
        key.integer = obj;
 
173
        for (int32_t i=startIndex; i<count; ++i) {
 
174
            if ((*comparer)(key, elements[i])) {
 
175
                return i;
 
176
            }
 
177
        }
 
178
    }
 
179
    return -1;
 
180
}
 
181
 
165
182
UBool UVector::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) {
166
183
    if (capacity >= minimumCapacity) {
167
184
        return TRUE;