src/java.base/share/classes/java/text/CollationKey.java
changeset 58288 48e480e56aad
parent 58242 94bb65cb37d3
child 58679 9c3209ff7550
equal deleted inserted replaced
58287:a7f16447085e 58288:48e480e56aad
    37  */
    37  */
    38 
    38 
    39 package java.text;
    39 package java.text;
    40 
    40 
    41 /**
    41 /**
    42  * A <code>CollationKey</code> represents a <code>String</code> under the
    42  * A {@code CollationKey} represents a {@code String} under the
    43  * rules of a specific <code>Collator</code> object. Comparing two
    43  * rules of a specific {@code Collator} object. Comparing two
    44  * <code>CollationKey</code>s returns the relative order of the
    44  * {@code CollationKey}s returns the relative order of the
    45  * <code>String</code>s they represent. Using <code>CollationKey</code>s
    45  * {@code String}s they represent. Using {@code CollationKey}s
    46  * to compare <code>String</code>s is generally faster than using
    46  * to compare {@code String}s is generally faster than using
    47  * <code>Collator.compare</code>. Thus, when the <code>String</code>s
    47  * {@code Collator.compare}. Thus, when the {@code String}s
    48  * must be compared multiple times, for example when sorting a list
    48  * must be compared multiple times, for example when sorting a list
    49  * of <code>String</code>s. It's more efficient to use <code>CollationKey</code>s.
    49  * of {@code String}s. It's more efficient to use {@code CollationKey}s.
    50  *
    50  *
    51  * <p>
    51  * <p>
    52  * You can not create <code>CollationKey</code>s directly. Rather,
    52  * You can not create {@code CollationKey}s directly. Rather,
    53  * generate them by calling <code>Collator.getCollationKey</code>.
    53  * generate them by calling {@code Collator.getCollationKey}.
    54  * You can only compare <code>CollationKey</code>s generated from
    54  * You can only compare {@code CollationKey}s generated from
    55  * the same <code>Collator</code> object.
    55  * the same {@code Collator} object.
    56  *
    56  *
    57  * <p>
    57  * <p>
    58  * Generating a <code>CollationKey</code> for a <code>String</code>
    58  * Generating a {@code CollationKey} for a {@code String}
    59  * involves examining the entire <code>String</code>
    59  * involves examining the entire {@code String}
    60  * and converting it to series of bits that can be compared bitwise. This
    60  * and converting it to series of bits that can be compared bitwise. This
    61  * allows fast comparisons once the keys are generated. The cost of generating
    61  * allows fast comparisons once the keys are generated. The cost of generating
    62  * keys is recouped in faster comparisons when <code>String</code>s need
    62  * keys is recouped in faster comparisons when {@code String}s need
    63  * to be compared many times. On the other hand, the result of a comparison
    63  * to be compared many times. On the other hand, the result of a comparison
    64  * is often determined by the first couple of characters of each <code>String</code>.
    64  * is often determined by the first couple of characters of each {@code String}.
    65  * <code>Collator.compare</code> examines only as many characters as it needs which
    65  * {@code Collator.compare} examines only as many characters as it needs which
    66  * allows it to be faster when doing single comparisons.
    66  * allows it to be faster when doing single comparisons.
    67  * <p>
    67  * <p>
    68  * The following example shows how <code>CollationKey</code>s might be used
    68  * The following example shows how {@code CollationKey}s might be used
    69  * to sort a list of <code>String</code>s.
    69  * to sort a list of {@code String}s.
    70  * <blockquote>
    70  * <blockquote>
    71  * <pre>{@code
    71  * <pre>{@code
    72  * // Create an array of CollationKeys for the Strings to be sorted.
    72  * // Create an array of CollationKeys for the Strings to be sorted.
    73  * Collator myCollator = Collator.getInstance();
    73  * Collator myCollator = Collator.getInstance();
    74  * CollationKey[] keys = new CollationKey[3];
    74  * CollationKey[] keys = new CollationKey[3];