All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.implementations.persistentOrderedMap.PersistentOrderedMapContentViews.kt Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2016-2019 JetBrains s.r.o.
 * Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
 */

package kotlinx.collections.immutable.implementations.persistentOrderedMap

import kotlinx.collections.immutable.ImmutableCollection
import kotlinx.collections.immutable.ImmutableSet
import kotlinx.collections.immutable.internal.MapImplementation

internal class PersistentOrderedMapEntries(private val map: PersistentOrderedMap) : ImmutableSet>, AbstractSet>() {
    override val size: Int get() = map.size

    override fun contains(element: Map.Entry): Boolean {
        return MapImplementation.containsEntry(map, element)
    }

    override fun iterator(): Iterator> {
        return PersistentOrderedMapEntriesIterator(map)
    }
}

internal class PersistentOrderedMapKeys(private val map: PersistentOrderedMap) : ImmutableSet, AbstractSet() {
    override val size: Int
        get() = map.size

    override fun contains(element: K): Boolean {
        return map.containsKey(element)
    }

    override fun iterator(): Iterator {
        return PersistentOrderedMapKeysIterator(map)
    }
}

internal class PersistentOrderedMapValues(private val map: PersistentOrderedMap) : ImmutableCollection, AbstractCollection() {
    override val size: Int
        get() = map.size

    override fun contains(element: V): Boolean {
        return map.containsValue(element)
    }

    override fun iterator(): Iterator {
        return PersistentOrderedMapValuesIterator(map)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy