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

com.skillw.pouvoir.internal.feature.hologram.ConcurrentHashSet.kt Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
package com.skillw.pouvoir.internal.feature.hologram

import java.io.Serializable
import java.util.*
import java.util.concurrent.ConcurrentHashMap

/**
 * @className ConcrrentSet
 *
 * @author Glom
 * @date 2022/7/28 11:37 Copyright 2022 user.
 */
class ConcurrentHashSet : AbstractSet(), Serializable {
    private val map = ConcurrentHashMap()

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

    override fun add(element: E): Boolean {
        return map.putIfAbsent(element, java.lang.Boolean.TRUE) == null
    }

    override fun remove(element: E): Boolean {
        return map.remove(element ?: return false) != null
    }

    override fun clear() {
        map.clear()
    }

    override fun iterator(): MutableIterator {
        return map.keys.iterator()
    }

    companion object {
        private const val serialVersionUID = -6761513279741915432L
    }

    override val size: Int
        get() = map.size
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy