/*
**********************************************************************
-* Copyright (C) 2013, International Business Machines
+* Copyright (C) 2014, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
#include "scriptset.h"
#include "uassert.h"
+#include "cmemory.h"
U_NAMESPACE_BEGIN
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
//----------------------------------------------------------------------------
//
// ScriptSet implementation
//
//----------------------------------------------------------------------------
ScriptSet::ScriptSet() {
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
bits[i] = 0;
}
}
ScriptSet & ScriptSet::operator =(const ScriptSet &other) {
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
bits[i] = other.bits[i];
}
return *this;
UBool ScriptSet::operator == (const ScriptSet &other) const {
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
if (bits[i] != other.bits[i]) {
return FALSE;
}
ScriptSet &ScriptSet::Union(const ScriptSet &other) {
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
bits[i] |= other.bits[i];
}
return *this;
}
ScriptSet &ScriptSet::intersect(const ScriptSet &other) {
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
bits[i] &= other.bits[i];
}
return *this;
}
UBool ScriptSet::intersects(const ScriptSet &other) const {
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
if ((bits[i] & other.bits[i]) != 0) {
return true;
}
ScriptSet &ScriptSet::setAll() {
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
bits[i] = 0xffffffffu;
}
return *this;
ScriptSet &ScriptSet::resetAll() {
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
bits[i] = 0;
}
return *this;
// This bit counter is good for sparse numbers of '1's, which is
// very much the case that we will usually have.
int32_t count = 0;
- for (uint32_t i=0; i<LENGTHOF(bits); i++) {
+ for (uint32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
uint32_t x = bits[i];
while (x > 0) {
count++;
int32_t ScriptSet::hashCode() const {
int32_t hash = 0;
- for (int32_t i=0; i<LENGTHOF(bits); i++) {
+ for (int32_t i=0; i<UPRV_LENGTHOF(bits); i++) {
hash ^= bits[i];
}
return hash;
UBool firstTime = TRUE;
for (int32_t i = nextSetBit(0); i >= 0; i = nextSetBit(i + 1)) {
if (!firstTime) {
- dest.append(0x20);
+ dest.append((UChar)0x20);
}
firstTime = FALSE;
const char *scriptName = uscript_getShortName((UScriptCode(i)));