intl/icu/source/common/ustack.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/ustack.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +/*
     1.5 +**********************************************************************
     1.6 +*   Copyright (C) 2003-2011, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +**********************************************************************
     1.9 +*/
    1.10 +
    1.11 +#include "uvector.h"
    1.12 +
    1.13 +U_NAMESPACE_BEGIN
    1.14 +
    1.15 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UStack)
    1.16 +
    1.17 +UStack::UStack(UErrorCode &status) :
    1.18 +    UVector(status)
    1.19 +{
    1.20 +}
    1.21 +
    1.22 +UStack::UStack(int32_t initialCapacity, UErrorCode &status) :
    1.23 +    UVector(initialCapacity, status)
    1.24 +{
    1.25 +}
    1.26 +
    1.27 +UStack::UStack(UObjectDeleter *d, UElementsAreEqual *c, UErrorCode &status) :
    1.28 +    UVector(d, c, status)
    1.29 +{
    1.30 +}
    1.31 +
    1.32 +UStack::UStack(UObjectDeleter *d, UElementsAreEqual *c, int32_t initialCapacity, UErrorCode &status) :
    1.33 +    UVector(d, c, initialCapacity, status)
    1.34 +{
    1.35 +}
    1.36 +
    1.37 +UStack::~UStack() {}
    1.38 +
    1.39 +void* UStack::pop(void) {
    1.40 +    int32_t n = size() - 1;
    1.41 +    void* result = 0;
    1.42 +    if (n >= 0) {
    1.43 +        result = elementAt(n);
    1.44 +        removeElementAt(n);
    1.45 +    }
    1.46 +    return result;
    1.47 +}
    1.48 +
    1.49 +int32_t UStack::popi(void) {
    1.50 +    int32_t n = size() - 1;
    1.51 +    int32_t result = 0;
    1.52 +    if (n >= 0) {
    1.53 +        result = elementAti(n);
    1.54 +        removeElementAt(n);
    1.55 +    }
    1.56 +    return result;
    1.57 +}
    1.58 +
    1.59 +int32_t UStack::search(void* obj) const {
    1.60 +    int32_t i = indexOf(obj);
    1.61 +    return (i >= 0) ? size() - i : i;
    1.62 +}
    1.63 +
    1.64 +U_NAMESPACE_END

mercurial