diff --git a/nebulosa-image-format/src/main/kotlin/nebulosa/image/format/AbstractHeader.kt b/nebulosa-image-format/src/main/kotlin/nebulosa/image/format/AbstractHeader.kt index 8fdb541a9..2181ae75a 100644 --- a/nebulosa-image-format/src/main/kotlin/nebulosa/image/format/AbstractHeader.kt +++ b/nebulosa-image-format/src/main/kotlin/nebulosa/image/format/AbstractHeader.kt @@ -3,8 +3,7 @@ package nebulosa.image.format import java.io.Serializable import java.util.* -abstract class AbstractHeader protected constructor(@JvmField protected val cards: LinkedList) : - Header, MutableCollection by cards, Serializable { +abstract class AbstractHeader protected constructor(@JvmField protected val cards: LinkedList) : Header, Serializable { constructor() : this(LinkedList()) @@ -27,6 +26,41 @@ abstract class AbstractHeader protected constructor(@JvmField protected val card } } + override val size + get() = cards.size + + override fun contains(element: HeaderCard): Boolean { + return element in cards + } + + override fun containsAll(elements: Collection): Boolean { + return cards.containsAll(elements) + } + + override fun isEmpty(): Boolean { + return cards.isEmpty() + } + + override fun iterator(): MutableIterator { + return cards.iterator() + } + + override fun clear() { + cards.clear() + } + + override fun remove(element: HeaderCard): Boolean { + return cards.remove(element) + } + + override fun removeAll(elements: Collection): Boolean { + return cards.removeAll(elements.toSet()) + } + + override fun retainAll(elements: Collection): Boolean { + return cards.retainAll(elements.toSet()) + } + override fun delete(key: String): Boolean { return cards.removeIf { it.key == key } } diff --git a/nebulosa-image-format/src/main/kotlin/nebulosa/image/format/WritableHeader.kt b/nebulosa-image-format/src/main/kotlin/nebulosa/image/format/WritableHeader.kt index 4a6f4c017..abcc50f2b 100644 --- a/nebulosa-image-format/src/main/kotlin/nebulosa/image/format/WritableHeader.kt +++ b/nebulosa-image-format/src/main/kotlin/nebulosa/image/format/WritableHeader.kt @@ -20,6 +20,8 @@ interface WritableHeader : MutableCollection { fun addAll(cards: Iterable) = cards.forEach(::add) + override fun addAll(elements: Collection) = elements.fold(false) { a, b -> add(b) || a } + fun delete(key: HeaderKey) = delete(key.key) fun delete(key: String): Boolean