[TIL] 20201211

todo

What I learned

  • Map 인터페이스를 살펴보았다. *Set<K> keysCollection<V> values, 그리고 key-value 쌍을 저장하고 있는 Set<Map.Entry<K, V> 가 있다.
    • 그리고 해당 Map에 key와 value 값이 있는지를 각각 검사하는 containsKey()와 containsValue() 추상메소드가 있다.
package kotlin.collections

public interface Map<K, out V> {
    public val size: Int

    public fun isEmpty(): Boolean

    public fun containsKey(key: K): Boolean
    public fun containsValue(value: @UnsafeVariance V): Boolean

    public operator fun get(key: K): V?
    
    /**
     * Returns a read-only [Set] of all keys in this map.
     */
    public val keys: Set<K>

    /**
     * Returns a read-only [Collection] of all values in this map. Note that this collection may contain duplicate values.
     */
    public val values: Collection<V>

    /**
     * Returns a read-only [Set] of all key/value pairs in this map.
     */
    public val entries: Set<Map.Entry<K, V>>

    public interface Entry<out K, out V> {
        public val key: K

        public val value: V
    }
}

Tags:

Categories:

Updated:

Leave a comment