// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** * Copyright (C) 1999-2011, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** */ // // UVector32 is a class implementing a vector of 32 bit integers. // It is similar to UVector, but holds int32_t values rather than pointers. // Most of the code is unchanged from UVector. // #ifndef UVECTOR32_H #define UVECTOR32_H #include "unicode/utypes.h" #include "unicode/uobject.h" #include "uhash.h" #include "uassert.h" U_NAMESPACE_BEGIN /** * <p>Ultralightweight C++ implementation of a <tt>void*</tt> vector * that is (mostly) compatible with java.util.Vector. * * <p>This is a very simple implementation, written to satisfy an * immediate porting need. As such, it is not completely fleshed out, * and it aims for simplicity and conformity. Nonetheless, it serves * its purpose (porting code from java that uses java.util.Vector) * well, and it could be easily made into a more robust vector class. * * <p><b>Design notes</b> * * <p>There is index bounds checking, but little is done about it. If * indices are out of bounds, either nothing happens, or zero is * returned. We <em>do</em> avoid indexing off into the weeds. * * <p>There is detection of out of memory, but the handling is very * coarse-grained -- similar to UnicodeString's protocol, but even * coarser. The class contains <em>one static flag</em> that is set * when any call to <tt>new</tt> returns zero. This allows the caller * to use several vectors and make just one check at the end to see if * a memory failure occurred. This is more efficient than making a * check after each call on each vector when doing many operations on * multiple vectors. The single static flag works best when memory * failures are infrequent, and when recovery options are limited or * nonexistent. * * <p><b>To do</b> * * <p>Improve the handling of index out of bounds errors. * * @author Alan Liu */ class U_COMMON_API UVector32 : public UObject { … }; // UVector32 inlines inline UBool UVector32::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) { … } inline int32_t UVector32::elementAti(int32_t index) const { … } inline void UVector32::addElement(int32_t elem, UErrorCode &status) { … } inline int32_t *UVector32::reserveBlock(int32_t size, UErrorCode &status) { … } inline int32_t *UVector32::popFrame(int32_t size) { … } inline int32_t UVector32::size() const { … } inline UBool UVector32::isEmpty() const { … } inline UBool UVector32::contains(int32_t obj) const { … } inline int32_t UVector32::lastElementi() const { … } inline bool UVector32::operator!=(const UVector32& other) const { … } inline int32_t *UVector32::getBuffer() const { … } // UStack inlines inline UBool UVector32::empty() const { … } inline int32_t UVector32::peeki() const { … } inline int32_t UVector32::push(int32_t i, UErrorCode &status) { … } inline int32_t UVector32::popi() { … } U_NAMESPACE_END #endif