]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/uvectr32.h
ICU-64243.0.1.tar.gz
[apple/icu.git] / icuSources / common / uvectr32.h
index bec5dd42e707ed12815588e6f3c150c251ccc8c9..ba47daa75f16135bb1181090c4d44a292b4ad19b 100644 (file)
@@ -1,6 +1,8 @@
+// © 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.
 **********************************************************************
 */
@@ -95,21 +97,21 @@ public:
     // 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;
 
@@ -121,9 +123,9 @@ public:
 
     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);
@@ -161,7 +163,7 @@ public:
     /**
      * 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.
@@ -195,23 +197,23 @@ private:
     //  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);
@@ -219,7 +221,7 @@ inline UBool UVector32::ensureCapacity(int32_t minimumCapacity, UErrorCode &stat
 }
 
 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;
 }