Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
1 /*
2 **********************************************************************
3 * Copyright (C) 2003-2011, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 */
8 #include "uvector.h"
10 U_NAMESPACE_BEGIN
12 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UStack)
14 UStack::UStack(UErrorCode &status) :
15 UVector(status)
16 {
17 }
19 UStack::UStack(int32_t initialCapacity, UErrorCode &status) :
20 UVector(initialCapacity, status)
21 {
22 }
24 UStack::UStack(UObjectDeleter *d, UElementsAreEqual *c, UErrorCode &status) :
25 UVector(d, c, status)
26 {
27 }
29 UStack::UStack(UObjectDeleter *d, UElementsAreEqual *c, int32_t initialCapacity, UErrorCode &status) :
30 UVector(d, c, initialCapacity, status)
31 {
32 }
34 UStack::~UStack() {}
36 void* UStack::pop(void) {
37 int32_t n = size() - 1;
38 void* result = 0;
39 if (n >= 0) {
40 result = elementAt(n);
41 removeElementAt(n);
42 }
43 return result;
44 }
46 int32_t UStack::popi(void) {
47 int32_t n = size() - 1;
48 int32_t result = 0;
49 if (n >= 0) {
50 result = elementAti(n);
51 removeElementAt(n);
52 }
53 return result;
54 }
56 int32_t UStack::search(void* obj) const {
57 int32_t i = indexOf(obj);
58 return (i >= 0) ? size() - i : i;
59 }
61 U_NAMESPACE_END