annotate modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/i18n/ucoleitr.cpp @ 11038:20a8447c71c6

8207159: Update ICU to version 62.1 Reviewed-by: mbilla, kcr, ghb
author arajkumar
date Fri, 24 Aug 2018 15:06:40 +0530
parents fee4ef5c87df
children
rev   line source
arajkumar@11038 1 // © 2016 and later: Unicode, Inc. and others.
arajkumar@11038 2 // License & terms of use: http://www.unicode.org/copyright.html
ghb@10550 3 /*
ghb@10550 4 ******************************************************************************
arajkumar@11038 5 * Copyright (C) 2001-2016, International Business Machines
ghb@10550 6 * Corporation and others. All Rights Reserved.
ghb@10550 7 ******************************************************************************
ghb@10550 8 *
ghb@10550 9 * File ucoleitr.cpp
ghb@10550 10 *
ghb@10550 11 * Modification History:
ghb@10550 12 *
ghb@10550 13 * Date Name Description
ghb@10550 14 * 02/15/2001 synwee Modified all methods to process its own function
ghb@10550 15 * instead of calling the equivalent c++ api (coleitr.h)
arajkumar@11038 16 * 2012-2014 markus Rewritten in C++ again.
ghb@10550 17 ******************************************************************************/
ghb@10550 18
ghb@10550 19 #include "unicode/utypes.h"
ghb@10550 20
ghb@10550 21 #if !UCONFIG_NO_COLLATION
ghb@10550 22
arajkumar@11038 23 #include "unicode/coleitr.h"
arajkumar@11038 24 #include "unicode/tblcoll.h"
ghb@10550 25 #include "unicode/ucoleitr.h"
ghb@10550 26 #include "unicode/ustring.h"
ghb@10550 27 #include "unicode/sortkey.h"
ghb@10550 28 #include "unicode/uobject.h"
ghb@10550 29 #include "cmemory.h"
arajkumar@11038 30 #include "usrchimp.h"
ghb@10550 31
ghb@10550 32 U_NAMESPACE_USE
ghb@10550 33
ghb@10550 34 #define BUFFER_LENGTH 100
ghb@10550 35
ghb@10550 36 #define DEFAULT_BUFFER_SIZE 16
ghb@10550 37 #define BUFFER_GROW 8
ghb@10550 38
arajkumar@11038 39 #define ARRAY_COPY(dst, src, count) uprv_memcpy((void *) (dst), (void *) (src), (size_t)(count) * sizeof (src)[0])
ghb@10550 40
arajkumar@11038 41 #define NEW_ARRAY(type, count) (type *) uprv_malloc((size_t)(count) * sizeof(type))
ghb@10550 42
ghb@10550 43 #define DELETE_ARRAY(array) uprv_free((void *) (array))
ghb@10550 44
ghb@10550 45 struct RCEI
ghb@10550 46 {
ghb@10550 47 uint32_t ce;
ghb@10550 48 int32_t low;
ghb@10550 49 int32_t high;
ghb@10550 50 };
ghb@10550 51
ghb@10550 52 U_NAMESPACE_BEGIN
ghb@10550 53
ghb@10550 54 struct RCEBuffer
ghb@10550 55 {
ghb@10550 56 RCEI defaultBuffer[DEFAULT_BUFFER_SIZE];
ghb@10550 57 RCEI *buffer;
ghb@10550 58 int32_t bufferIndex;
ghb@10550 59 int32_t bufferSize;
ghb@10550 60
ghb@10550 61 RCEBuffer();
ghb@10550 62 ~RCEBuffer();
ghb@10550 63
arajkumar@11038 64 UBool isEmpty() const;
arajkumar@11038 65 void put(uint32_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &errorCode);
ghb@10550 66 const RCEI *get();
ghb@10550 67 };
ghb@10550 68
ghb@10550 69 RCEBuffer::RCEBuffer()
ghb@10550 70 {
ghb@10550 71 buffer = defaultBuffer;
ghb@10550 72 bufferIndex = 0;
arajkumar@11038 73 bufferSize = UPRV_LENGTHOF(defaultBuffer);
ghb@10550 74 }
ghb@10550 75
ghb@10550 76 RCEBuffer::~RCEBuffer()
ghb@10550 77 {
ghb@10550 78 if (buffer != defaultBuffer) {
ghb@10550 79 DELETE_ARRAY(buffer);
ghb@10550 80 }
ghb@10550 81 }
ghb@10550 82
arajkumar@11038 83 UBool RCEBuffer::isEmpty() const
ghb@10550 84 {
ghb@10550 85 return bufferIndex <= 0;
ghb@10550 86 }
ghb@10550 87
arajkumar@11038 88 void RCEBuffer::put(uint32_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &errorCode)
ghb@10550 89 {
arajkumar@11038 90 if (U_FAILURE(errorCode)) {
arajkumar@11038 91 return;
arajkumar@11038 92 }
ghb@10550 93 if (bufferIndex >= bufferSize) {
ghb@10550 94 RCEI *newBuffer = NEW_ARRAY(RCEI, bufferSize + BUFFER_GROW);
arajkumar@11038 95 if (newBuffer == NULL) {
arajkumar@11038 96 errorCode = U_MEMORY_ALLOCATION_ERROR;
arajkumar@11038 97 return;
arajkumar@11038 98 }
ghb@10550 99
ghb@10550 100 ARRAY_COPY(newBuffer, buffer, bufferSize);
ghb@10550 101
ghb@10550 102 if (buffer != defaultBuffer) {
ghb@10550 103 DELETE_ARRAY(buffer);
ghb@10550 104 }
ghb@10550 105
ghb@10550 106 buffer = newBuffer;
ghb@10550 107 bufferSize += BUFFER_GROW;
ghb@10550 108 }
ghb@10550 109
ghb@10550 110 buffer[bufferIndex].ce = ce;
ghb@10550 111 buffer[bufferIndex].low = ixLow;
ghb@10550 112 buffer[bufferIndex].high = ixHigh;
ghb@10550 113
ghb@10550 114 bufferIndex += 1;
ghb@10550 115 }
ghb@10550 116
ghb@10550 117 const RCEI *RCEBuffer::get()
ghb@10550 118 {
ghb@10550 119 if (bufferIndex > 0) {
ghb@10550 120 return &buffer[--bufferIndex];
ghb@10550 121 }
ghb@10550 122
ghb@10550 123 return NULL;
ghb@10550 124 }
ghb@10550 125
ghb@10550 126 PCEBuffer::PCEBuffer()
ghb@10550 127 {
ghb@10550 128 buffer = defaultBuffer;
ghb@10550 129 bufferIndex = 0;
arajkumar@11038 130 bufferSize = UPRV_LENGTHOF(defaultBuffer);
ghb@10550 131 }
ghb@10550 132
ghb@10550 133 PCEBuffer::~PCEBuffer()
ghb@10550 134 {
ghb@10550 135 if (buffer != defaultBuffer) {
ghb@10550 136 DELETE_ARRAY(buffer);
ghb@10550 137 }
ghb@10550 138 }
ghb@10550 139
ghb@10550 140 void PCEBuffer::reset()
ghb@10550 141 {
ghb@10550 142 bufferIndex = 0;
ghb@10550 143 }
ghb@10550 144
arajkumar@11038 145 UBool PCEBuffer::isEmpty() const
ghb@10550 146 {
ghb@10550 147 return bufferIndex <= 0;
ghb@10550 148 }
ghb@10550 149
arajkumar@11038 150 void PCEBuffer::put(uint64_t ce, int32_t ixLow, int32_t ixHigh, UErrorCode &errorCode)
ghb@10550 151 {
arajkumar@11038 152 if (U_FAILURE(errorCode)) {
arajkumar@11038 153 return;
arajkumar@11038 154 }
ghb@10550 155 if (bufferIndex >= bufferSize) {
ghb@10550 156 PCEI *newBuffer = NEW_ARRAY(PCEI, bufferSize + BUFFER_GROW);
arajkumar@11038 157 if (newBuffer == NULL) {
arajkumar@11038 158 errorCode = U_MEMORY_ALLOCATION_ERROR;
arajkumar@11038 159 return;
arajkumar@11038 160 }
ghb@10550 161
ghb@10550 162 ARRAY_COPY(newBuffer, buffer, bufferSize);
ghb@10550 163
ghb@10550 164 if (buffer != defaultBuffer) {
ghb@10550 165 DELETE_ARRAY(buffer);
ghb@10550 166 }
ghb@10550 167
ghb@10550 168 buffer = newBuffer;
ghb@10550 169 bufferSize += BUFFER_GROW;
ghb@10550 170 }
ghb@10550 171
ghb@10550 172 buffer[bufferIndex].ce = ce;
ghb@10550 173 buffer[bufferIndex].low = ixLow;
ghb@10550 174 buffer[bufferIndex].high = ixHigh;
ghb@10550 175
ghb@10550 176 bufferIndex += 1;
ghb@10550 177 }
ghb@10550 178
ghb@10550 179 const PCEI *PCEBuffer::get()
ghb@10550 180 {
ghb@10550 181 if (bufferIndex > 0) {
ghb@10550 182 return &buffer[--bufferIndex];
ghb@10550 183 }
ghb@10550 184
ghb@10550 185 return NULL;
ghb@10550 186 }
ghb@10550 187
arajkumar@11038 188 UCollationPCE::UCollationPCE(UCollationElements *elems) { init(elems); }
ghb@10550 189
arajkumar@11038 190 UCollationPCE::UCollationPCE(CollationElementIterator *iter) { init(iter); }
ghb@10550 191
arajkumar@11038 192 void UCollationPCE::init(UCollationElements *elems) {
arajkumar@11038 193 init(CollationElementIterator::fromUCollationElements(elems));
ghb@10550 194 }
ghb@10550 195
arajkumar@11038 196 void UCollationPCE::init(CollationElementIterator *iter)
arajkumar@11038 197 {
arajkumar@11038 198 cei = iter;
arajkumar@11038 199 init(*iter->rbc_);
arajkumar@11038 200 }
arajkumar@11038 201
arajkumar@11038 202 void UCollationPCE::init(const Collator &coll)
ghb@10550 203 {
ghb@10550 204 UErrorCode status = U_ZERO_ERROR;
ghb@10550 205
arajkumar@11038 206 strength = coll.getAttribute(UCOL_STRENGTH, status);
arajkumar@11038 207 toShift = coll.getAttribute(UCOL_ALTERNATE_HANDLING, status) == UCOL_SHIFTED;
ghb@10550 208 isShifted = FALSE;
arajkumar@11038 209 variableTop = coll.getVariableTop(status);
ghb@10550 210 }
ghb@10550 211
ghb@10550 212 UCollationPCE::~UCollationPCE()
ghb@10550 213 {
ghb@10550 214 // nothing to do
ghb@10550 215 }
ghb@10550 216
arajkumar@11038 217 uint64_t UCollationPCE::processCE(uint32_t ce)
ghb@10550 218 {
ghb@10550 219 uint64_t primary = 0, secondary = 0, tertiary = 0, quaternary = 0;
ghb@10550 220
ghb@10550 221 // This is clean, but somewhat slow...
ghb@10550 222 // We could apply the mask to ce and then
ghb@10550 223 // just get all three orders...
arajkumar@11038 224 switch(strength) {
ghb@10550 225 default:
ghb@10550 226 tertiary = ucol_tertiaryOrder(ce);
arajkumar@11038 227 U_FALLTHROUGH;
ghb@10550 228
ghb@10550 229 case UCOL_SECONDARY:
ghb@10550 230 secondary = ucol_secondaryOrder(ce);
arajkumar@11038 231 U_FALLTHROUGH;
ghb@10550 232
ghb@10550 233 case UCOL_PRIMARY:
ghb@10550 234 primary = ucol_primaryOrder(ce);
ghb@10550 235 }
ghb@10550 236
ghb@10550 237 // **** This should probably handle continuations too. ****
ghb@10550 238 // **** That means that we need 24 bits for the primary ****
ghb@10550 239 // **** instead of the 16 that we're currently using. ****
ghb@10550 240 // **** So we can lay out the 64 bits as: 24.12.12.16. ****
ghb@10550 241 // **** Another complication with continuations is that ****
ghb@10550 242 // **** the *second* CE is marked as a continuation, so ****
ghb@10550 243 // **** we always have to peek ahead to know how long ****
ghb@10550 244 // **** the primary is... ****
arajkumar@11038 245 if ((toShift && variableTop > ce && primary != 0)
arajkumar@11038 246 || (isShifted && primary == 0)) {
ghb@10550 247
ghb@10550 248 if (primary == 0) {
ghb@10550 249 return UCOL_IGNORABLE;
ghb@10550 250 }
ghb@10550 251
arajkumar@11038 252 if (strength >= UCOL_QUATERNARY) {
ghb@10550 253 quaternary = primary;
ghb@10550 254 }
ghb@10550 255
ghb@10550 256 primary = secondary = tertiary = 0;
arajkumar@11038 257 isShifted = TRUE;
ghb@10550 258 } else {
arajkumar@11038 259 if (strength >= UCOL_QUATERNARY) {
ghb@10550 260 quaternary = 0xFFFF;
ghb@10550 261 }
ghb@10550 262
arajkumar@11038 263 isShifted = FALSE;
ghb@10550 264 }
ghb@10550 265
ghb@10550 266 return primary << 48 | secondary << 32 | tertiary << 16 | quaternary;
ghb@10550 267 }
ghb@10550 268
arajkumar@11038 269 U_NAMESPACE_END
ghb@10550 270
ghb@10550 271 /* public methods ---------------------------------------------------- */
ghb@10550 272
ghb@10550 273 U_CAPI UCollationElements* U_EXPORT2
ghb@10550 274 ucol_openElements(const UCollator *coll,
ghb@10550 275 const UChar *text,
ghb@10550 276 int32_t textLength,
ghb@10550 277 UErrorCode *status)
ghb@10550 278 {
ghb@10550 279 if (U_FAILURE(*status)) {
ghb@10550 280 return NULL;
ghb@10550 281 }
arajkumar@11038 282 if (coll == NULL || (text == NULL && textLength != 0)) {
arajkumar@11038 283 *status = U_ILLEGAL_ARGUMENT_ERROR;
arajkumar@11038 284 return NULL;
arajkumar@11038 285 }
arajkumar@11038 286 const RuleBasedCollator *rbc = RuleBasedCollator::rbcFromUCollator(coll);
arajkumar@11038 287 if (rbc == NULL) {
arajkumar@11038 288 *status = U_UNSUPPORTED_ERROR; // coll is a Collator but not a RuleBasedCollator
arajkumar@11038 289 return NULL;
arajkumar@11038 290 }
ghb@10550 291
arajkumar@11038 292 UnicodeString s((UBool)(textLength < 0), text, textLength);
arajkumar@11038 293 CollationElementIterator *cei = rbc->createCollationElementIterator(s);
arajkumar@11038 294 if (cei == NULL) {
ghb@10550 295 *status = U_MEMORY_ALLOCATION_ERROR;
ghb@10550 296 return NULL;
ghb@10550 297 }
ghb@10550 298
arajkumar@11038 299 return cei->toUCollationElements();
ghb@10550 300 }
ghb@10550 301
ghb@10550 302
ghb@10550 303 U_CAPI void U_EXPORT2
ghb@10550 304 ucol_closeElements(UCollationElements *elems)
ghb@10550 305 {
arajkumar@11038 306 delete CollationElementIterator::fromUCollationElements(elems);
ghb@10550 307 }
ghb@10550 308
ghb@10550 309 U_CAPI void U_EXPORT2
ghb@10550 310 ucol_reset(UCollationElements *elems)
ghb@10550 311 {
arajkumar@11038 312 CollationElementIterator::fromUCollationElements(elems)->reset();
ghb@10550 313 }
ghb@10550 314
ghb@10550 315 U_CAPI int32_t U_EXPORT2
ghb@10550 316 ucol_next(UCollationElements *elems,
ghb@10550 317 UErrorCode *status)
ghb@10550 318 {
ghb@10550 319 if (U_FAILURE(*status)) {
ghb@10550 320 return UCOL_NULLORDER;
ghb@10550 321 }
ghb@10550 322
arajkumar@11038 323 return CollationElementIterator::fromUCollationElements(elems)->next(*status);
ghb@10550 324 }
ghb@10550 325
arajkumar@11038 326 U_NAMESPACE_BEGIN
arajkumar@11038 327
arajkumar@11038 328 int64_t
arajkumar@11038 329 UCollationPCE::nextProcessed(
ghb@10550 330 int32_t *ixLow,
ghb@10550 331 int32_t *ixHigh,
ghb@10550 332 UErrorCode *status)
ghb@10550 333 {
ghb@10550 334 int64_t result = UCOL_IGNORABLE;
ghb@10550 335 uint32_t low = 0, high = 0;
ghb@10550 336
ghb@10550 337 if (U_FAILURE(*status)) {
ghb@10550 338 return UCOL_PROCESSED_NULLORDER;
ghb@10550 339 }
ghb@10550 340
arajkumar@11038 341 pceBuffer.reset();
ghb@10550 342
ghb@10550 343 do {
arajkumar@11038 344 low = cei->getOffset();
arajkumar@11038 345 int32_t ce = cei->next(*status);
arajkumar@11038 346 high = cei->getOffset();
ghb@10550 347
arajkumar@11038 348 if (ce == UCOL_NULLORDER) {
ghb@10550 349 result = UCOL_PROCESSED_NULLORDER;
ghb@10550 350 break;
ghb@10550 351 }
ghb@10550 352
arajkumar@11038 353 result = processCE((uint32_t)ce);
ghb@10550 354 } while (result == UCOL_IGNORABLE);
ghb@10550 355
ghb@10550 356 if (ixLow != NULL) {
ghb@10550 357 *ixLow = low;
ghb@10550 358 }
ghb@10550 359
ghb@10550 360 if (ixHigh != NULL) {
ghb@10550 361 *ixHigh = high;
ghb@10550 362 }
ghb@10550 363
ghb@10550 364 return result;
ghb@10550 365 }
ghb@10550 366
arajkumar@11038 367 U_NAMESPACE_END
arajkumar@11038 368
ghb@10550 369 U_CAPI int32_t U_EXPORT2
ghb@10550 370 ucol_previous(UCollationElements *elems,
ghb@10550 371 UErrorCode *status)
ghb@10550 372 {
ghb@10550 373 if(U_FAILURE(*status)) {
ghb@10550 374 return UCOL_NULLORDER;
ghb@10550 375 }
arajkumar@11038 376 return CollationElementIterator::fromUCollationElements(elems)->previous(*status);
ghb@10550 377 }
ghb@10550 378
arajkumar@11038 379 U_NAMESPACE_BEGIN
arajkumar@11038 380
arajkumar@11038 381 int64_t
arajkumar@11038 382 UCollationPCE::previousProcessed(
ghb@10550 383 int32_t *ixLow,
ghb@10550 384 int32_t *ixHigh,
ghb@10550 385 UErrorCode *status)
ghb@10550 386 {
ghb@10550 387 int64_t result = UCOL_IGNORABLE;
ghb@10550 388 int32_t low = 0, high = 0;
ghb@10550 389
ghb@10550 390 if (U_FAILURE(*status)) {
ghb@10550 391 return UCOL_PROCESSED_NULLORDER;
ghb@10550 392 }
ghb@10550 393
arajkumar@11038 394 // pceBuffer.reset();
ghb@10550 395
arajkumar@11038 396 while (pceBuffer.isEmpty()) {
ghb@10550 397 // buffer raw CEs up to non-ignorable primary
ghb@10550 398 RCEBuffer rceb;
arajkumar@11038 399 int32_t ce;
ghb@10550 400
ghb@10550 401 // **** do we need to reset rceb, or will it always be empty at this point ****
ghb@10550 402 do {
arajkumar@11038 403 high = cei->getOffset();
arajkumar@11038 404 ce = cei->previous(*status);
arajkumar@11038 405 low = cei->getOffset();
ghb@10550 406
arajkumar@11038 407 if (ce == UCOL_NULLORDER) {
arajkumar@11038 408 if (!rceb.isEmpty()) {
ghb@10550 409 break;
ghb@10550 410 }
ghb@10550 411
ghb@10550 412 goto finish;
ghb@10550 413 }
ghb@10550 414
arajkumar@11038 415 rceb.put((uint32_t)ce, low, high, *status);
arajkumar@11038 416 } while (U_SUCCESS(*status) && ((ce & UCOL_PRIMARYORDERMASK) == 0 || isContinuation(ce)));
ghb@10550 417
ghb@10550 418 // process the raw CEs
arajkumar@11038 419 while (U_SUCCESS(*status) && !rceb.isEmpty()) {
ghb@10550 420 const RCEI *rcei = rceb.get();
ghb@10550 421
arajkumar@11038 422 result = processCE(rcei->ce);
ghb@10550 423
ghb@10550 424 if (result != UCOL_IGNORABLE) {
arajkumar@11038 425 pceBuffer.put(result, rcei->low, rcei->high, *status);
ghb@10550 426 }
ghb@10550 427 }
arajkumar@11038 428 if (U_FAILURE(*status)) {
arajkumar@11038 429 return UCOL_PROCESSED_NULLORDER;
arajkumar@11038 430 }
ghb@10550 431 }
ghb@10550 432
ghb@10550 433 finish:
arajkumar@11038 434 if (pceBuffer.isEmpty()) {
ghb@10550 435 // **** Is -1 the right value for ixLow, ixHigh? ****
ghb@10550 436 if (ixLow != NULL) {
ghb@10550 437 *ixLow = -1;
ghb@10550 438 }
ghb@10550 439
ghb@10550 440 if (ixHigh != NULL) {
ghb@10550 441 *ixHigh = -1
ghb@10550 442 ;
ghb@10550 443 }
ghb@10550 444 return UCOL_PROCESSED_NULLORDER;
ghb@10550 445 }
ghb@10550 446
arajkumar@11038 447 const PCEI *pcei = pceBuffer.get();
ghb@10550 448
ghb@10550 449 if (ixLow != NULL) {
ghb@10550 450 *ixLow = pcei->low;
ghb@10550 451 }
ghb@10550 452
ghb@10550 453 if (ixHigh != NULL) {
ghb@10550 454 *ixHigh = pcei->high;
ghb@10550 455 }
ghb@10550 456
ghb@10550 457 return pcei->ce;
ghb@10550 458 }
ghb@10550 459
arajkumar@11038 460 U_NAMESPACE_END
arajkumar@11038 461
ghb@10550 462 U_CAPI int32_t U_EXPORT2
ghb@10550 463 ucol_getMaxExpansion(const UCollationElements *elems,
ghb@10550 464 int32_t order)
ghb@10550 465 {
arajkumar@11038 466 return CollationElementIterator::fromUCollationElements(elems)->getMaxExpansion(order);
ghb@10550 467
arajkumar@11038 468 // TODO: The old code masked the order according to strength and then did a binary search.
arajkumar@11038 469 // However this was probably at least partially broken because of the following comment.
arajkumar@11038 470 // Still, it might have found a match when this version may not.
ghb@10550 471
ghb@10550 472 // FIXME: with a masked search, there might be more than one hit,
ghb@10550 473 // so we need to look forward and backward from the match to find all
ghb@10550 474 // of the hits...
ghb@10550 475 }
ghb@10550 476
ghb@10550 477 U_CAPI void U_EXPORT2
ghb@10550 478 ucol_setText( UCollationElements *elems,
ghb@10550 479 const UChar *text,
ghb@10550 480 int32_t textLength,
ghb@10550 481 UErrorCode *status)
ghb@10550 482 {
ghb@10550 483 if (U_FAILURE(*status)) {
ghb@10550 484 return;
ghb@10550 485 }
ghb@10550 486
arajkumar@11038 487 if ((text == NULL && textLength != 0)) {
arajkumar@11038 488 *status = U_ILLEGAL_ARGUMENT_ERROR;
arajkumar@11038 489 return;
ghb@10550 490 }
arajkumar@11038 491 UnicodeString s((UBool)(textLength < 0), text, textLength);
arajkumar@11038 492 return CollationElementIterator::fromUCollationElements(elems)->setText(s, *status);
ghb@10550 493 }
ghb@10550 494
ghb@10550 495 U_CAPI int32_t U_EXPORT2
ghb@10550 496 ucol_getOffset(const UCollationElements *elems)
ghb@10550 497 {
arajkumar@11038 498 return CollationElementIterator::fromUCollationElements(elems)->getOffset();
ghb@10550 499 }
ghb@10550 500
ghb@10550 501 U_CAPI void U_EXPORT2
ghb@10550 502 ucol_setOffset(UCollationElements *elems,
ghb@10550 503 int32_t offset,
ghb@10550 504 UErrorCode *status)
ghb@10550 505 {
ghb@10550 506 if (U_FAILURE(*status)) {
ghb@10550 507 return;
ghb@10550 508 }
ghb@10550 509
arajkumar@11038 510 CollationElementIterator::fromUCollationElements(elems)->setOffset(offset, *status);
ghb@10550 511 }
ghb@10550 512
ghb@10550 513 U_CAPI int32_t U_EXPORT2
ghb@10550 514 ucol_primaryOrder (int32_t order)
ghb@10550 515 {
arajkumar@11038 516 return (order >> 16) & 0xffff;
ghb@10550 517 }
ghb@10550 518
ghb@10550 519 U_CAPI int32_t U_EXPORT2
ghb@10550 520 ucol_secondaryOrder (int32_t order)
ghb@10550 521 {
arajkumar@11038 522 return (order >> 8) & 0xff;
ghb@10550 523 }
ghb@10550 524
ghb@10550 525 U_CAPI int32_t U_EXPORT2
ghb@10550 526 ucol_tertiaryOrder (int32_t order)
ghb@10550 527 {
arajkumar@11038 528 return order & 0xff;
ghb@10550 529 }
ghb@10550 530
ghb@10550 531 #endif /* #if !UCONFIG_NO_COLLATION */