Stay organized with collections
Save and categorize content based on your preferences.
ImmutableIndex
class ImmutableIndex<V : Any!> : MutableIterable<AlphabeticIndex.Bucket<V>!>
Immutable, thread-safe version of AlphabeticIndex
. This class provides thread-safe methods for bucketing, and random access to buckets and their properties, but does not offer adding records to the index.
Summary
Public methods |
AlphabeticIndex.Bucket<V>! |
Returns the index-th bucket.
|
Int |
Returns the number of index buckets and labels, including underflow/inflow/overflow.
|
Int |
Finds the index bucket for the given name and returns the number of that bucket.
|
MutableIterator<AlphabeticIndex.Bucket<V>!> |
Returns an iterator over elements of type T .
|
Public methods
getBucket
fun getBucket(index: Int): AlphabeticIndex.Bucket<V>!
Returns the index-th bucket. Returns null if the index is out of range.
Parameters |
index |
Int: bucket number |
getBucketCount
fun getBucketCount(): Int
Returns the number of index buckets and labels, including underflow/inflow/overflow.
Return |
Int |
the number of index buckets |
getBucketIndex
fun getBucketIndex(name: CharSequence!): Int
Finds the index bucket for the given name and returns the number of that bucket. Use getBucket(int)
to get the bucket's properties.
Parameters |
name |
CharSequence!: the string to be sorted into an index bucket |
Return |
Int |
the bucket number for the name |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# AlphabeticIndex.ImmutableIndex\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nImmutableIndex\n==============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/icu/text/AlphabeticIndex.ImmutableIndex \"View this page in Java\") \n\n```\nclass ImmutableIndex\u003cV : Any!\u003e : MutableIterable\u003cAlphabeticIndex.Bucket\u003cV\u003e!\u003e\n```\n\n|---|------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.icu.text.AlphabeticIndex.ImmutableIndex](#) |\n\nImmutable, thread-safe version of [AlphabeticIndex](/reference/kotlin/android/icu/text/AlphabeticIndex). This class provides thread-safe methods for bucketing, and random access to buckets and their properties, but does not offer adding records to the index.\n\nSummary\n-------\n\n| Public methods ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [AlphabeticIndex.Bucket](/reference/kotlin/android/icu/text/AlphabeticIndex.Bucket)\\\u003cV\\\u003e! | [getBucket](#getBucket(kotlin.Int))`(`index:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the index-th bucket. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getBucketCount](#getBucketCount())`()` Returns the number of index buckets and labels, including underflow/inflow/overflow. |\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [getBucketIndex](#getBucketIndex(kotlin.CharSequence))`(`name:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` Finds the index bucket for the given name and returns the number of that bucket. |\n| [MutableIterator](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-iterator/index.html)\\\u003c[AlphabeticIndex.Bucket](/reference/kotlin/android/icu/text/AlphabeticIndex.Bucket)\\\u003cV\\\u003e!\\\u003e | [iterator](#iterator())`()` Returns an iterator over elements of type `T`. |\n\nPublic methods\n--------------\n\n### getBucket\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getBucket(index: Int): AlphabeticIndex.Bucket\u003cV\u003e!\n```\n\nReturns the index-th bucket. Returns null if the index is out of range.\n\n| Parameters ||\n|---------|-------------------------------------------------------------------------------------------|\n| `index` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): bucket number |\n\n| Return ||\n|-----------------------------------------------------------------------------------------|---------------------|\n| [AlphabeticIndex.Bucket](/reference/kotlin/android/icu/text/AlphabeticIndex.Bucket)\u003cV\u003e! | the index-th bucket |\n\n### getBucketCount\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getBucketCount(): Int\n```\n\nReturns the number of index buckets and labels, including underflow/inflow/overflow.\n\n| Return ||\n|----------------------------------------------------------------------------|-----------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the number of index buckets |\n\n### getBucketIndex\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getBucketIndex(name: CharSequence!): Int\n```\n\nFinds the index bucket for the given name and returns the number of that bucket. Use [getBucket(int)](#getBucket(kotlin.Int)) to get the bucket's properties.\n\n| Parameters ||\n|--------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `name` | [CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!: the string to be sorted into an index bucket |\n\n| Return ||\n|----------------------------------------------------------------------------|--------------------------------|\n| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | the bucket number for the name |\n\n### iterator\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun iterator(): MutableIterator\u003cAlphabeticIndex.Bucket\u003cV\u003e!\u003e\n```\n\nReturns an iterator over elements of type `T`.\n\n| Return ||\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|\n| [MutableIterator](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-iterator/index.html)\u003c[AlphabeticIndex.Bucket](/reference/kotlin/android/icu/text/AlphabeticIndex.Bucket)\u003cV\u003e!\u003e | an Iterator. |"]]