ICU-6678 add uset_openEmpty()

X-SVN-Rev: 25451
This commit is contained in:
Markus Scherer 2009-02-19 23:36:58 +00:00
parent 1bdabd9519
commit 97ea1827e7
5 changed files with 28 additions and 18 deletions

View file

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2002-2008, International Business Machines
* Copyright (C) 2002-2009, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -242,10 +242,20 @@ typedef struct USerializedSet {
* USet API
*********************************************************************/
/**
* Create an empty USet object.
* Equivalent to uset_open(1, 0).
* @return a newly created USet. The caller must call uset_close() on
* it when done.
* @draft ICU 4.2
*/
U_DRAFT USet* U_EXPORT2
uset_openEmpty();
/**
* Creates a USet object that contains the range of characters
* start..end, inclusive. If <code>start > end</code>
* then an empty set is created.
* then an empty set is created (same as using uset_openEmpty()).
* @param start first character of the range, inclusive
* @param end last character of the range, inclusive
* @return a newly created USet. The caller must call uset_close() on

View file

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 2002-2007, International Business Machines
* Copyright (C) 2002-2009, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -13,9 +13,6 @@
* created on: 2002mar07
* created by: Markus W. Scherer
*
* The serialized structure, the array of range limits, is
* the same as in UnicodeSet, except that the HIGH value is not stored.
*
* There are functions to efficiently serialize a USet into an array of uint16_t
* and functions to use such a serialized form efficiently without
* instantiating a new USet.
@ -31,6 +28,11 @@
U_NAMESPACE_USE
U_CAPI USet* U_EXPORT2
uset_openEmpty() {
return (USet*) new UnicodeSet();
}
U_CAPI USet* U_EXPORT2
uset_open(UChar32 start, UChar32 end) {
return (USet*) new UnicodeSet(start, end);

View file

@ -39,11 +39,6 @@ U_NAMESPACE_BEGIN
#define DELETE_ARRAY(array) uprv_free((void *) (array))
#define ARRAY_COPY(dst, src, count) uprv_memcpy((void *) (dst), (void *) (src), (count) * sizeof (src)[0])
static inline USet *uset_openEmpty()
{
return uset_open(1, 0);
}
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(CEList)
#ifdef INSTRUMENT_CELIST

View file

@ -1,6 +1,6 @@
/*
**********************************************************************
* Copyright (c) 2002-2008, International Business Machines
* Copyright (c) 2002-2009, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
@ -84,6 +84,14 @@ static void TestAPI() {
UErrorCode ec;
/* [] */
set = uset_openEmpty();
expect(set, "", "abc{ab}", NULL);
uset_close(set);
set = uset_open(1, 0);
expect(set, "", "abc{ab}", NULL);
uset_close(set);
set = uset_open(1, 1);
uset_clear(set);
expect(set, "", "abc{ab}", NULL);

View file

@ -1070,7 +1070,7 @@ static UnicodeString &escape(const UnicodeString &string, UnicodeString &buffer)
return buffer;
}
static USet *uset_openEmpty();
#if 1
struct PCE
@ -1775,11 +1775,6 @@ static void generateTestCase(UCollator *coll, Monkey *monkeys[], int32_t monkeyC
} while (! matches);
}
static inline USet *uset_openEmpty()
{
return uset_open(1, 0);
}
//
// Find the next acceptable boundary following the specified starting index
// in the target text being searched.