View

interface View<out T> : Iterable<T>

一个“视图”。视图的主要应用是对使用者提供一个只读的集合类型,类似于 Collection。 但是它不实现 Collection 或相关接口,而是提供一些较为基础的、与 Collection 相似的方法。

View 中的元素可能是变化的,线程安全性也与其内部实际表示的原集合相关。 但是这些变化对外界不可见,它不论面向什么平台(比如JVM平台)都是一种更安全的只读集合。

Author

ForteScarlet

Functions

Link copied to clipboard
abstract operator fun contains(element: @UnsafeVariance T): Boolean

判断当前视图中是否包含指定元素。

Link copied to clipboard
open fun forEach(p0: Consumer<in T>)
Link copied to clipboard
abstract fun isEmpty(): Boolean

判断当前视图是否为空。

Link copied to clipboard
abstract operator override fun iterator(): Iterator<T>

得到当前视图的迭代器。

Link copied to clipboard

Properties

Link copied to clipboard
abstract val size: Int

获取当前视图中的元素数量。

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Extensions

Link copied to clipboard
Link copied to clipboard
fun <T> Iterable<T>.asView(): View<T>

构建一个当前 Iterable 对应的 View。 如果当前类型为 Collection, 则相当于 Collection.asView

Link copied to clipboard
Link copied to clipboard
inline fun <T> View<T>.isNotEmpty(): Boolean

判断当前视图是否不为空。

Link copied to clipboard
Link copied to clipboard
fun <T> View<T>.toList(): List<T>

View 转化为 List.

Link copied to clipboard

将 元素为 MsgElementIterable 转化为 Messages 实例。