+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
-* Copyright (C) 1999-2008, International Business Machines
+* Copyright (C) 1999-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
// java.util.Vector API
//------------------------------------------------------------
- void addElement(int32_t elem, UErrorCode &status);
+ inline void addElement(int32_t elem, UErrorCode &status);
void setElementAt(int32_t elem, int32_t index);
void insertElementAt(int32_t elem, int32_t index, UErrorCode &status);
- int32_t elementAti(int32_t index) const;
+ inline int32_t elementAti(int32_t index) const;
UBool equals(const UVector32 &other) const;
- int32_t lastElementi(void) const;
+ inline int32_t lastElementi(void) const;
int32_t indexOf(int32_t elem, int32_t startIndex = 0) const;
- UBool contains(int32_t elem) const;
+ inline UBool contains(int32_t elem) const;
UBool containsAll(const UVector32& other) const;
void removeAllElements();
- int32_t size(void) const;
+ inline int32_t size(void) const;
- UBool isEmpty(void) const;
+ inline UBool isEmpty(void) const;
// Inline. Use this one for speedy size check.
inline UBool ensureCapacity(int32_t minimumCapacity, UErrorCode &status);
/**
* Returns a pointer to the internal array holding the vector.
*/
- int32_t *getBuffer() const;
+ inline int32_t *getBuffer() const;
/**
* Set the maximum allowed buffer capacity for this vector/stack.
// In the original UVector, these were in a separate derived class, UStack.
// Here in UVector32, they are all together.
public:
- UBool empty(void) const; // TODO: redundant, same as empty(). Remove it?
+ inline UBool empty(void) const; // TODO: redundant, same as empty(). Remove it?
- int32_t peeki(void) const;
+ inline int32_t peeki(void) const;
- int32_t popi(void);
+ inline int32_t popi(void);
- int32_t push(int32_t i, UErrorCode &status);
+ inline int32_t push(int32_t i, UErrorCode &status);
- int32_t *reserveBlock(int32_t size, UErrorCode &status);
- int32_t *popFrame(int32_t size);
+ inline int32_t *reserveBlock(int32_t size, UErrorCode &status);
+ inline int32_t *popFrame(int32_t size);
};
// UVector32 inlines
inline UBool UVector32::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) {
- if (capacity >= minimumCapacity) {
+ if ((minimumCapacity >= 0) && (capacity >= minimumCapacity)) {
return TRUE;
} else {
return expandCapacity(minimumCapacity, status);
}
inline int32_t UVector32::elementAti(int32_t index) const {
- return (0 <= index && index < count) ? elements[index] : 0;
+ return (index >= 0 && count > 0 && count - index > 0) ? elements[index] : 0;
}