]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/nfrlist.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
5 * Copyright (C) 1997-2012, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
10 * tab size: 8 (not used)
13 * Modification history
15 * 10/11/2001 Doug Ported from ICU4J
21 #include "unicode/rbnf.h"
25 #include "unicode/uobject.h"
32 // unsafe class for internal use only. assume memory allocations succeed, indexes are valid.
33 // should be a template, but we can't use them
35 class NFRuleList
: public UMemory
{
41 NFRuleList(uint32_t capacity
= 10)
42 : fStuff(capacity
? (NFRule
**)uprv_malloc(capacity
* sizeof(NFRule
*)) : NULL
)
44 , fCapacity(capacity
) {}
47 for(uint32_t i
= 0; i
< fCount
; ++i
) {
53 NFRule
* operator[](uint32_t index
) const { return fStuff
!= NULL
? fStuff
[index
] : NULL
; }
54 NFRule
* remove(uint32_t index
) {
58 NFRule
* result
= fStuff
[index
];
60 for (uint32_t i
= index
; i
< fCount
; ++i
) { // assumes small arrays
61 fStuff
[i
] = fStuff
[i
+1];
65 void add(NFRule
* thing
) {
66 if (fCount
== fCapacity
) {
68 fStuff
= (NFRule
**)uprv_realloc(fStuff
, fCapacity
* sizeof(NFRule
*)); // assume success
71 fStuff
[fCount
++] = thing
;
77 uint32_t size() const { return fCount
; }
78 NFRule
* last() const { return (fCount
> 0 && fStuff
!= NULL
) ? fStuff
[fCount
-1] : NULL
; }
80 add(NULL
); // ensure null termination
81 NFRule
** result
= fStuff
;
89 int32_t size
= fCount
;
92 for (int32_t i
= 0; i
< size
; i
++) {
102 NFRuleList(const NFRuleList
&other
); // forbid copying of this class
103 NFRuleList
&operator=(const NFRuleList
&other
); // forbid copying of this class