// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** * Copyright (C) 1999-2014, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** */ // // UVector64 is a class implementing a vector of 64 bit integers. // It is similar to UVector32, but holds int64_t values rather than int32_t. // Most of the code is unchanged from UVector. // #ifndef UVECTOR64_H #define UVECTOR64_H #include "unicode/utypes.h" #include "unicode/uobject.h" #include "uhash.h" #include "uassert.h" U_NAMESPACE_BEGIN /** * <p>Ultralightweight C++ implementation of an <tt>int64_t</tt> vector * that has a subset of methods from UVector32 * * <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. * */ class U_COMMON_API UVector64 : public UObject { … }; // UVector64 inlines inline UBool UVector64::ensureCapacity(int32_t minimumCapacity, UErrorCode &status) { … } inline int64_t UVector64::elementAti(int32_t index) const { … } inline void UVector64::addElement(int64_t elem, UErrorCode &status) { … } inline int64_t *UVector64::reserveBlock(int32_t size, UErrorCode &status) { … } inline int64_t *UVector64::popFrame(int32_t size) { … } inline int32_t UVector64::size() const { … } inline int64_t UVector64::lastElementi() const { … } inline bool UVector64::operator!=(const UVector64& other) { … } inline int64_t *UVector64::getBuffer() const { … } // UStack inlines inline int64_t UVector64::push(int64_t i, UErrorCode &status) { … } inline int64_t UVector64::popi() { … } U_NAMESPACE_END #endif