1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.runtime
.cldc
.util
;
12 import java
.util
.AbstractSet
;
13 import java
.util
.Iterator
;
17 * This is the key set for an abstract map.
19 * @param <K> The key type.
20 * @param <V> The value stored.
23 public final class MapKeySetView
<K
, V
>
24 extends AbstractSet
<K
>
26 /** The backing map. */
27 protected final Map
<K
, V
> map
;
29 /** Is adding allowed? */
30 protected final boolean allowAdd
;
33 * Initializes the set.
35 * @param __map The backing map
36 * @param __allowAdd Is adding allowed in the map?
37 * @throws NullPointerException On null arguments.
40 public MapKeySetView(Map
<K
, V
> __map
, boolean __allowAdd
)
41 throws NullPointerException
44 throw new NullPointerException("NARG");
47 this.allowAdd
= __allowAdd
;
55 public boolean add(K __k
)
58 throw new UnsupportedOperationException("RORO");
60 // Store a null value here
61 Map
<K
, V
> map
= this.map
;
62 boolean contained
= map
.containsKey(__k
);
65 // Only if it is actually contained here
73 @SuppressWarnings("SuspiciousMethodCalls")
75 public final boolean contains(Object __o
)
77 return this.map
.containsKey(__o
);
85 public final Iterator
<K
> iterator()
87 return new __MapKeySetIterator__
<K
, V
>(this.map
.entrySet().iterator());
94 @SuppressWarnings("SuspiciousMethodCalls")
96 public boolean remove(Object __o
)
98 // Remove the item from the map, but check to ensure it has it before
99 // that is actually done
100 Map
<K
, V
> map
= this.map
;
101 boolean hasKey
= map
.containsKey(__o
);
112 public final int size()
114 return this.map
.size();