]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/nfrlist.h
2 ******************************************************************************
3 * Copyright (C) 1997-2001, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************
8 * tab size: 8 (not used)
11 * Modification history
13 * 10/11/2001 Doug Ported from ICU4J
19 #include "unicode/rbnf.h"
23 #include "unicode/uobject.h"
30 // unsafe class for internal use only. assume memory allocations succeed, indexes are valid.
31 // should be a template, but we can't use them
33 class NFRuleList
: public UMemory
{
39 NFRuleList(int capacity
= 10)
40 : fStuff(capacity
? (NFRule
**)uprv_malloc(capacity
* sizeof(NFRule
*)) : NULL
)
42 , fCapacity(capacity
) {};
45 for(uint32_t i
= 0; i
< fCount
; ++i
) {
51 NFRule
* operator[](uint32_t index
) const { return fStuff
[index
]; }
52 NFRule
* remove(uint32_t index
) {
53 NFRule
* result
= fStuff
[index
];
55 for (uint32_t i
= index
; i
< fCount
; ++i
) { // assumes small arrays
56 fStuff
[i
] = fStuff
[i
+1];
60 void add(NFRule
* thing
) {
61 if (fCount
== fCapacity
) {
63 fStuff
= (NFRule
**)uprv_realloc(fStuff
, fCapacity
* sizeof(NFRule
*)); // assume success
65 fStuff
[fCount
++] = thing
;
67 uint32_t size() const { return fCount
; }
68 NFRule
* last() const { return fCount
> 0 ? fStuff
[fCount
-1] : NULL
; }
70 add(NULL
); // ensure null termination
71 NFRule
** result
= fStuff
;
79 NFRuleList(const NFRuleList
&other
); // forbid copying of this class
80 NFRuleList
&operator=(const NFRuleList
&other
); // forbid copying of this class