From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- intl/icu/source/i18n/collationweights.h | 113 ++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 intl/icu/source/i18n/collationweights.h (limited to 'intl/icu/source/i18n/collationweights.h') diff --git a/intl/icu/source/i18n/collationweights.h b/intl/icu/source/i18n/collationweights.h new file mode 100644 index 0000000000..0d20b927b2 --- /dev/null +++ b/intl/icu/source/i18n/collationweights.h @@ -0,0 +1,113 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +/* +******************************************************************************* +* +* Copyright (C) 1999-2014, International Business Machines +* Corporation and others. All Rights Reserved. +* +******************************************************************************* +* file name: collationweights.h +* encoding: UTF-8 +* tab size: 8 (not used) +* indentation:4 +* +* created on: 2001mar08 as ucol_wgt.h +* created by: Markus W. Scherer +*/ + +#ifndef __COLLATIONWEIGHTS_H__ +#define __COLLATIONWEIGHTS_H__ + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_COLLATION + +#include "unicode/uobject.h" + +U_NAMESPACE_BEGIN + +/** + * Allocates n collation element weights between two exclusive limits. + * Used only internally by the collation tailoring builder. + */ +class U_I18N_API CollationWeights : public UMemory { +public: + CollationWeights(); + + static inline int32_t lengthOfWeight(uint32_t weight) { + if((weight&0xffffff)==0) { + return 1; + } else if((weight&0xffff)==0) { + return 2; + } else if((weight&0xff)==0) { + return 3; + } else { + return 4; + } + } + + void initForPrimary(UBool compressible); + void initForSecondary(); + void initForTertiary(); + + /** + * Determine heuristically + * what ranges to use for a given number of weights between (excluding) + * two limits. + * + * @param lowerLimit A collation element weight; the ranges will be filled to cover + * weights greater than this one. + * @param upperLimit A collation element weight; the ranges will be filled to cover + * weights less than this one. + * @param n The number of collation element weights w necessary such that + * lowerLimit