Glad that's over with
This commit is contained in:
parent
bcb6aa480a
commit
f08b26a4a2
@ -0,0 +1,813 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>MapASDV.java</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
||||
.number {color: #6897bb}
|
||||
.string {color: #6a8759}
|
||||
.ST1 {color: #9876aa}
|
||||
.ST3 {color: #ffc66d}
|
||||
.ST4 {color: #8a653b}
|
||||
.comment {color: #808080}
|
||||
.whitespace {color: #505050}
|
||||
.ST5 {color: #9876aa; font-family: monospace; font-weight: bold; font-style: italic}
|
||||
.ST6 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
|
||||
.ST0 {color: #287bde}
|
||||
.literal {color: #cc7832}
|
||||
.ST2 {font-family: monospace; font-weight: bold; font-style: italic}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 4/Assignments/MapASDV_CalebFontenot/src/mapasdv_calebfontenot/MapASDV.java</td></tr></table>
|
||||
<pre>
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
|
||||
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
|
||||
<span class="comment"> */</span>
|
||||
<span class="literal">package</span> mapasdv_calebfontenot;
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="comment">//import ListASDV;</span>
|
||||
<span class="literal">import</span> java.util.ArrayList;
|
||||
<span class="literal">import</span> java.util.Collection;
|
||||
<span class="literal">import</span> java.util.HashMap;
|
||||
<span class="literal">import</span> java.util.HashSet;
|
||||
<span class="literal">import</span> java.util.Iterator;
|
||||
<span class="literal">import</span> java.util.Map;
|
||||
<span class="literal">import</span> java.util.Objects;
|
||||
<span class="literal">import</span> java.util.Set;
|
||||
<span class="literal">import</span> java.util.function.BiConsumer;<span class="comment">//needed in putAll</span>
|
||||
|
||||
<span class="literal">public</span> <span class="literal">class</span> MapASDV<K, V> <span class="literal">implements</span> Map<K, V>, Cloneable {
|
||||
|
||||
<span class="literal">private</span> <span class="literal">int</span> <span class="ST1">capacity</span> = <span class="number">4</span>;
|
||||
<span class="literal">private</span> <span class="literal">double</span> <span class="comment">loadFactor</span> = <span class="number">0.75</span>;
|
||||
<span class="literal">private</span> ArrayList<ListASDV<EntryASDV<K, V>>> <span class="ST1">map</span> = <span class="literal">new</span> ArrayList<>();
|
||||
|
||||
<span class="literal">private</span> Set<K> <span class="ST1">sharedKeySet</span> = <span class="literal">new</span> SharedSet<>();
|
||||
<span class="literal">private</span> Set<<span class="ST2">Entry</span><K, V>> <span class="ST1">sharedEntrySet</span> = <span class="literal">new</span> SharedSet<>();
|
||||
<span class="literal">private</span> Collection<V> <span class="ST1">sharedValuesCollection</span> = <span class="literal">new</span> SharedCollection<>();
|
||||
|
||||
<span class="literal">private</span> <span class="literal">class</span> SharedCollection<V> <span class="literal">extends</span> ArrayList<V> {
|
||||
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">addValue</span>(V v) {
|
||||
<span class="literal">return</span> <span class="literal">this</span>.add(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">remove</span>(Object o) {
|
||||
|
||||
<span class="comment">//> The parameter is key not entry if we are here</span>
|
||||
<span class="comment">//>>remove value) and key) from the map</span>
|
||||
<span class="literal">return</span> MapASDV.<span class="literal">this</span>.removeFirstValue(o);
|
||||
|
||||
<span class="comment">//>>remove key from shared values set</span>
|
||||
<span class="comment">//return super.remove(o);</span>
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Removes</span> <span class="comment">one</span> <span class="comment">value</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">collection</span><span class="comment">.</span> <span class="comment">This</span> <span class="comment">method</span> <span class="comment">is</span> <span class="comment">meant</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">called</span> <span class="comment">from</span> <span class="comment">out</span> <span class="comment">class</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">overridden</span> <span class="comment">remove</span><span class="comment">(</span><span class="comment">Object</span> <span class="comment">o</span><span class="comment">) </span><span class="comment">of</span> <span class="comment">this</span> <span class="comment">inner</span> <span class="comment">class</span><span class="comment">, </span><span class="comment">calls</span> <span class="comment">the</span> <span class="comment">remove</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">outer</span> <span class="comment">class</span><span class="comment">(</span><span class="comment">MapASDV</span><span class="comment">), </span><span class="comment">and</span> <span class="comment">the</span> <span class="comment">remove</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">outer</span> <span class="comment">class</span><span class="comment">, </span><span class="comment">calls</span> <span class="comment">remove</span><span class="comment">(</span><span class="comment">V</span> <span class="comment">v</span><span class="comment">, </span><span class="comment">boolean</span> <span class="comment">callFromOuterClass</span><span class="comment">) </span><span class="comment">instead</span> <span class="comment">of</span> <span class="comment">remove</span><span class="comment">(</span><span class="comment">Object</span> <span class="comment">o</span><span class="comment">) </span><span class="comment">to</span> <span class="comment">avoid</span> <span class="comment">Stack</span> <span class="comment">Overflow</span> <span class="comment">when</span> <span class="comment">remover</span> <span class="comment">of</span> <span class="comment">inner</span> <span class="comment">calls</span> <span class="comment">remove</span> <span class="comment">of</span> <span class="comment">outer</span> <span class="comment">and</span> <span class="comment">vice</span> <span class="comment">versa</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">o</span><span class="comment"> - </span><span class="comment">the</span> <span class="comment">key</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">callFromOuterClass</span><span class="comment"> - </span><span class="comment">dummy</span> <span class="comment">variable</span><span class="comment">.</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">the</span> <span class="comment">key</span> <span class="comment">was</span> <span class="comment">removed</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">Set</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">remove</span>(V v, <span class="literal">boolean</span> callFromOuterClass) {
|
||||
<span class="comment">//remove key from shared keys set</span>
|
||||
<span class="literal">boolean</span> b = <span class="literal">super</span>.remove(v);
|
||||
<span class="literal">return</span> b;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> Object <span class="ST3">clone</span>() {
|
||||
<span class="literal">return</span> <span class="literal">super</span>.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">clear</span>() {
|
||||
<span class="literal">super</span>.clear();
|
||||
}
|
||||
}
|
||||
|
||||
<span class="literal">private</span> <span class="literal">class</span> SharedSet<E> <span class="literal">extends</span> HashSet<E> {
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">add</span>(E e) {
|
||||
<span class="literal">return</span> <span class="literal">super</span>.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">removeAll</span>(Collection<?> c) {
|
||||
<span class="literal">return</span> <span class="literal">super</span>.removeAll(c);
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Adds</span> <span class="comment">an</span> <span class="comment">EntryASDV</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">set</span><span class="comment">.</span> <span class="comment">It</span> <span class="comment">is</span> <span class="comment">private</span> <span class="comment">and</span> <span class="comment">cannot</span> <span class="comment">be</span> <span class="comment">used</span> <span class="comment">by</span> <span class="comment">the</span> <span class="comment">user</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">Set</span><span class="comment">.</span> <span class="comment">It</span> <span class="comment">is</span> <span class="comment">used</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">MapASDV</span> <span class="comment">to</span> <span class="comment">add</span> <span class="comment">EntriesASDV</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">SharedSet</span><span class="comment">.</span> <span class="comment">Without</span> <span class="comment">this</span> <span class="comment">method</span> <span class="comment">we</span> <span class="comment">wouldn</span><span class="comment">'</span><span class="comment">t</span> <span class="comment">be</span> <span class="comment">able</span> <span class="comment">to</span> <span class="comment">create</span> <span class="comment">a</span> <span class="comment">Set</span> <span class="comment">of</span> <span class="comment">keys</span> <span class="comment">or</span> <span class="comment">a</span> <span class="comment">Set</span> <span class="comment">of</span> <span class="comment">entries</span> <span class="comment">to</span> <span class="comment">give</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">user</span> <span class="comment">via</span> <span class="comment">methods</span> <span class="comment">keySet</span><span class="comment">() </span><span class="comment">and</span> <span class="comment">entrySet</span><span class="comment">() </span><span class="comment">of</span> <span class="comment">this</span> <span class="comment">Map</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">e</span> <span class="comment">EntryASDV</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">the</span> <span class="comment">entry</span> <span class="comment">was</span> <span class="comment">added</span> <span class="comment">false</span> <span class="comment">otherwise</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">private</span> <span class="literal">boolean</span> <span class="ST3">addEntry</span>(E e) {
|
||||
<span class="literal">return</span> <span class="literal">super</span>.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">remove</span>(Object o) {
|
||||
|
||||
<span class="comment">//>if parameter oo is EntryASDV call auxiliary method removeEntry</span>
|
||||
<span class="literal">if</span> (o <span class="literal">instanceof</span> EntryASDV) {
|
||||
<span class="literal">return</span> removeEntry((EntryASDV) o);
|
||||
}
|
||||
|
||||
<span class="comment">//> The parameter is key not entry if we are here</span>
|
||||
<span class="comment">//>>remove key from the map</span>
|
||||
MapASDV.<span class="literal">this</span>.remove(o);
|
||||
<span class="comment">//>>remove key from shared keys set</span>
|
||||
<span class="literal">return</span> <span class="literal">super</span>.remove(o);
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Removes</span> <span class="comment">the</span> <span class="comment">entry</span> <span class="comment">for</span> <span class="comment">the</span> <span class="comment">shared</span> <span class="comment">set</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">entry</span> <span class="comment">the</span> <span class="comment">entry</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">removed</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">the</span> <span class="comment">entry</span> <span class="comment">was</span> <span class="comment">removed</span><span class="comment">, </span><span class="comment">false</span> <span class="comment">otherwise</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">private</span> <span class="literal">boolean</span> <span class="ST3">removeEntry</span>(EntryASDV<K, V> entry) {
|
||||
|
||||
MapASDV.<span class="literal">this</span>.remove(entry.getKey());
|
||||
<span class="literal">return</span> <span class="literal">super</span>.remove(entry);
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Removes</span> <span class="comment">the</span> <span class="comment">key</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">set</span><span class="comment">.</span> <span class="comment">This</span> <span class="comment">method</span> <span class="comment">is</span> <span class="comment">meant</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">called</span> <span class="comment">from</span> <span class="comment">out</span> <span class="comment">class</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">overridden</span> <span class="comment">remove</span><span class="comment">(</span><span class="comment">Object</span> <span class="comment">o</span><span class="comment">) </span><span class="comment">of</span> <span class="comment">this</span> <span class="comment">inner</span> <span class="comment">class</span> <span class="comment">calls</span> <span class="comment">the</span> <span class="comment">remove</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">out</span> <span class="comment">class</span><span class="comment">, </span><span class="comment">and</span> <span class="comment">the</span> <span class="comment">remove</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">outer</span> <span class="comment">class</span> <span class="comment">calls</span> <span class="comment">remove</span><span class="comment">(</span><span class="comment">K</span> <span class="comment">o</span><span class="comment">, </span><span class="comment">boolean</span> <span class="comment">callFromOuterClass</span><span class="comment">) </span><span class="comment">instead</span> <span class="comment">of</span> <span class="comment">remove</span><span class="comment">(</span><span class="comment">Object</span> <span class="comment">o</span><span class="comment">) </span><span class="comment">to</span> <span class="comment">avoid</span> <span class="comment">Stack</span> <span class="comment">Overflow</span> <span class="comment">when</span> <span class="comment">remover</span> <span class="comment">of</span> <span class="comment">inner</span> <span class="comment">calls</span> <span class="comment">remove</span> <span class="comment">of</span> <span class="comment">outer</span> <span class="comment">and</span> <span class="comment">vice</span> <span class="comment">versa</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">o</span><span class="comment"> - </span><span class="comment">the</span> <span class="comment">key</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">callFromOuterClass</span><span class="comment"> - </span><span class="comment">dummy</span> <span class="comment">variable</span><span class="comment">.</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">the</span> <span class="comment">key</span> <span class="comment">was</span> <span class="comment">removed</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">Set</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">remove</span>(E o, <span class="literal">boolean</span> callFromOuterClass) {
|
||||
|
||||
<span class="comment">//remove key from shared keys set</span>
|
||||
<span class="literal">return</span> <span class="literal">super</span>.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> Object <span class="ST3">clone</span>() {
|
||||
<span class="literal">return</span> <span class="literal">super</span>.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">clear</span>() {
|
||||
<span class="literal">super</span>.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<span class="literal">public</span> MapASDV() {
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">capacity</span>; ++i) {
|
||||
<span class="ST1">map</span>.add(<span class="literal">new</span> ListASDV<EntryASDV<K, V>>());
|
||||
}
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Double</span> <span class="comment">the</span> <span class="comment">size</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">Map</span> <span class="comment">and</span> <span class="comment">rehashes</span> <span class="comment">the</span> <span class="comment">entries</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">Map</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">private</span> <span class="literal">void</span> <span class="ST3">doubleTheSizeOfTheMapAndRehash</span>() {
|
||||
<span class="ST1">capacity</span> *= <span class="number">2</span>;
|
||||
<span class="comment">//>create a new arrayList of ListsASDV</span>
|
||||
ArrayList<ListASDV<EntryASDV<K, V>>> newMap = <span class="literal">new</span> ArrayList<ListASDV<EntryASDV<K, V>>>();
|
||||
|
||||
<span class="comment">//>Add at every enetry of the arrayList a new ASDVList</span>
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">capacity</span>; ++i) {
|
||||
newMap.add(<span class="literal">new</span> ListASDV<EntryASDV<K, V>>());
|
||||
}
|
||||
|
||||
<span class="comment">//>for the size of the OLD arrayList</span>
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">map</span>.size(); ++i)<span class="comment">//array list</span>
|
||||
{
|
||||
<span class="comment">//>> get The ASDVlist at i</span>
|
||||
ListASDV<EntryASDV<K, V>> list = <span class="ST1">map</span>.get(i);
|
||||
|
||||
<span class="comment">//>>for the size() of the ASDVlist</span>
|
||||
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < list.size(); ++j) {
|
||||
<span class="comment">///>>>hash and put in the the new array </span>
|
||||
<span class="literal">int</span> index = hash(list.get(j).getKey().hashCode());
|
||||
newMap.get(index).add(list.get(j));
|
||||
|
||||
}
|
||||
}
|
||||
<span class="ST1">map</span> = newMap;
|
||||
}
|
||||
|
||||
<span class="literal">class</span> EntryASDV<K, V> <span class="literal">implements</span> <span class="ST2">Entry</span><K, V>, Comparable<K> {
|
||||
|
||||
K <span class="ST1">key</span>;
|
||||
V <span class="ST1">value</span>;
|
||||
|
||||
<span class="literal">public</span> EntryASDV(K key, V value) {
|
||||
<span class="literal">this</span>.<span class="ST1">key</span> = key;
|
||||
<span class="literal">this</span>.<span class="ST1">value</span> = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> K <span class="ST3">getKey</span>() {
|
||||
<span class="literal">return</span> <span class="ST1">key</span>;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> V <span class="ST3">getValue</span>() {
|
||||
<span class="literal">return</span> <span class="ST1">value</span>;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> V <span class="ST3">setValue</span>(V value) {
|
||||
V oldValue = <span class="literal">this</span>.<span class="ST1">value</span>;
|
||||
<span class="literal">this</span>.<span class="ST1">value</span> = value;
|
||||
<span class="literal">return</span> oldValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String <span class="ST3">toString</span>() {
|
||||
<span class="literal">return</span> <span class="string">"</span><span class="string">EntryASDV{</span><span class="string">"</span> + <span class="string">"</span><span class="string">key=</span><span class="string">"</span> + <span class="ST1">key</span> + <span class="string">"</span><span class="string">, value=</span><span class="string">"</span> + <span class="ST1">value</span> + <span class="string">'</span><span class="string">}</span><span class="string">'</span>;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">equals</span>(Object obj) {
|
||||
<span class="literal">if</span> (<span class="literal">this</span> == obj) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
<span class="literal">if</span> (obj == <span class="literal">null</span>) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">if</span> (getClass() != obj.getClass()) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">final</span> EntryASDV<?, ?> other = (EntryASDV<?, ?>) obj;
|
||||
<span class="literal">if</span> (!Objects.<span class="ST2">equals</span>(<span class="literal">t</span><span class="literal">his</span>.<span class="ST1">key</span>, other.<span class="ST1">key</span>)) {
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">o</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">throws</span> <span class="comment">IllegalArgumentException</span> <span class="comment">if</span> <span class="comment">parameter</span> <span class="comment">class</span> <span class="comment">is</span> <span class="comment">not</span> <span class="comment">K</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">int</span> <span class="ST3">compareTo</span>(K o) {
|
||||
<span class="literal">if</span> (getClass() != o.getClass()) {
|
||||
<span class="literal">throw</span> <span class="literal">new</span> IllegalArgumentException(<span class="string">"</span><span class="string">ellegal parameter </span><span class="string">"</span> + o);
|
||||
}
|
||||
<span class="literal">return</span> ((Comparable) <span class="ST1">key</span>).compareTo(o);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">int</span> <span class="ST3">size</span>() {
|
||||
<span class="literal">return</span> <span class="literal">this</span>.keySet().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">isEmpty</span>() {
|
||||
<span class="literal">if</span> (<span class="ST1">map</span>.size() == <span class="number">0</span>) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
|
||||
<span class="comment">// done</span>
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">containsKey</span>(Object key) {
|
||||
String dashes = <span class="string">"</span><span class="string">---------</span><span class="string">"</span>;
|
||||
System.<span class="ST5">out</span>.println(dashes + <span class="string">"</span><span class="string"> containsKey(</span><span class="string">"</span> + key.toString() + <span class="string">"</span><span class="string">) </span><span class="string">"</span> + dashes);
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">map</span>.size(); ++i) {
|
||||
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="ST1">map</span>.get(i).size(); ++j) {
|
||||
<span class="literal">if</span> (<span class="ST1">map</span>.get(i).get(j).<span class="ST1">key</span>.equals(key)) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Return</span> <span class="comment">an</span> <span class="comment">entry</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">map</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">key</span> <span class="comment">the</span> <span class="comment">key</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">entry</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">returned</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">the</span> <span class="comment">entry</span><span class="comment">, </span><span class="comment">or</span> <span class="comment">null</span> <span class="comment">if</span> <span class="comment">the</span> <span class="comment">key</span> <span class="comment">is</span> <span class="comment">not</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">map</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">private</span> EntryASDV<K, V> <span class="ST3">getEntryForKey</span>(Object key) {
|
||||
<span class="literal">for</span> (ListASDV<EntryASDV<K, V>> list : <span class="ST1">map</span>) {
|
||||
Iterator<EntryASDV<K, V>> it = list.iterator();
|
||||
<span class="literal">while</span> (it.hasNext()) {
|
||||
EntryASDV<K, V> entry = it.next();
|
||||
<span class="literal">if</span> (key.equals(entry.getKey())) {
|
||||
<span class="literal">return</span> entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
<span class="literal">return</span> <span class="literal">null</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Returns</span> <span class="comment">the</span> <span class="comment">index</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">given</span> <span class="comment">key</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">key</span> <span class="comment">a</span> <span class="comment">key</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">map</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">the</span> <span class="comment">index</span> <span class="comment">of</span> <span class="comment">a</span> <span class="comment">key</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">or</span><span class="comment"> -1, </span><span class="comment">if</span> <span class="comment">the</span> <span class="comment">key</span> <span class="comment">is</span> <span class="comment">not</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">map</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">private</span> <span class="literal">int</span> <span class="ST3">getIndexForKey</span>(Object key) {
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">map</span>.size(); ++i) {
|
||||
Iterator<EntryASDV<K, V>> it = <span class="ST1">map</span>.get(i).iterator();
|
||||
<span class="literal">while</span> (it.hasNext()) {
|
||||
EntryASDV<K, V> entry = it.next();
|
||||
<span class="literal">if</span> (key.equals(entry.getKey())) {
|
||||
<span class="literal">return</span> i;
|
||||
}
|
||||
}
|
||||
}
|
||||
<span class="literal">return</span> -<span class="number">1</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Returns</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">maps</span> <span class="comment">one</span> <span class="comment">or</span> <span class="comment">more</span> <span class="comment">keys</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">value</span><span class="comment">.</span> <span class="comment">More</span> <span class="comment">formally</span><span class="comment">, </span><span class="comment">returns</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">and</span> <span class="comment">only</span> <span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">contains</span> <span class="comment">at</span> <span class="comment">least</span> <span class="comment">one</span> <span class="comment">mapping</span> <span class="comment">to</span> <span class="comment">a</span> <span class="comment">value</span> <span class="comment">v</span> <span class="comment">such</span> <span class="comment">that</span><span class="comment"> (</span><span class="comment">value</span><span class="comment">==</span><span class="comment">null</span><span class="comment"> ? </span><span class="comment">v</span><span class="comment">==</span><span class="comment">null</span><span class="comment"> : </span><span class="comment">value</span><span class="comment">.</span><span class="comment">equals</span><span class="comment">(</span><span class="comment">v</span><span class="comment">))</span><span class="comment">.</span> <span class="comment">This</span> <span class="comment">operation</span> <span class="comment">will</span> <span class="comment">probably</span> <span class="comment">require</span> <span class="comment">time</span> <span class="comment">linear</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">size</span> <span class="comment">for</span> <span class="comment">most</span> <span class="comment">implementations</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">Map</span> <span class="comment">interface</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">Parameters</span><span class="comment">: </span><span class="comment">value</span><span class="comment"> - </span><span class="comment">value</span> <span class="comment">whose</span> <span class="comment">presence</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">is</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">tested</span> <span class="comment">Returns</span><span class="comment">: </span><span class="comment">true</span> <span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">maps</span> <span class="comment">one</span> <span class="comment">or</span> <span class="comment">more</span> <span class="comment">keys</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">value</span> <span class="comment">Throws</span><span class="comment">: </span><span class="comment">ClassCastException</span><span class="comment"> - </span><span class="comment">if</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">is</span> <span class="comment">of</span> <span class="comment">an</span> <span class="comment">inappropriate</span> <span class="comment">type</span> <span class="comment">for</span> <span class="comment">this</span> <span class="comment">map</span><span class="comment"> (</span><span class="comment">optional</span><span class="comment">) </span><span class="comment">NullPointerException</span><span class="comment"> - </span><span class="comment">if</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">value</span> <span class="comment">is</span> <span class="comment">null</span> <span class="comment">and</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">permit</span> <span class="comment">null</span> <span class="comment">values</span><span class="comment"> (</span><span class="comment">optional</span><span class="comment">)</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">value</span><span class="comment"> - </span><span class="comment">value</span> <span class="comment">whose</span> <span class="comment">presence</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">is</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">tested</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">maps</span> <span class="comment">one</span> <span class="comment">or</span> <span class="comment">more</span> <span class="comment">keys</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">value</span>
|
||||
<span class="comment"> * </span><span class="comment">@throws</span> <span class="comment">NullPointerException</span><span class="comment"> - </span><span class="comment">if</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">value</span> <span class="comment">is</span> <span class="comment">null</span> <span class="comment">and</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">permit</span> <span class="comment">null</span> <span class="comment">values</span><span class="comment"> (</span><span class="comment">optional</span><span class="comment">)</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="comment">//done</span>
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">boolean</span> <span class="ST3">containsValue</span>(Object value) {
|
||||
String dashes = <span class="string">"</span><span class="string">---------</span><span class="string">"</span>;
|
||||
System.<span class="ST5">out</span>.println(dashes + <span class="string">"</span><span class="string"> containsValue(</span><span class="string">"</span> + value.toString() + <span class="string">"</span><span class="string">) </span><span class="string">"</span> + dashes);
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">map</span>.size(); ++i) {
|
||||
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="ST1">map</span>.get(i).size(); ++j) {
|
||||
<span class="literal">if</span> (<span class="ST1">map</span>.get(i).get(j).<span class="ST1">value</span>.equals(value)) {
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Returns</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">to</span> <span class="comment">which</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">key</span> <span class="comment">is</span> <span class="comment">mapped</span><span class="comment">, </span><span class="comment">or</span> <span class="comment">null</span> <span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">contains</span> <span class="comment">no</span> <span class="comment">mapping</span> <span class="comment">for</span> <span class="comment">the</span> <span class="comment">key</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">More</span> <span class="comment">formally</span><span class="comment">, </span><span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">contains</span> <span class="comment">a</span> <span class="comment">mapping</span> <span class="comment">from</span> <span class="comment">a</span> <span class="comment">key</span> <span class="comment">k</span> <span class="comment">to</span> <span class="comment">a</span> <span class="comment">value</span> <span class="comment">v</span> <span class="comment">such</span> <span class="comment">that</span><span class="comment"> (</span><span class="comment">key</span><span class="comment">==</span><span class="comment">null</span><span class="comment"> ? </span><span class="comment">k</span><span class="comment">==</span><span class="comment">null</span><span class="comment"> : </span><span class="comment">key</span><span class="comment">.</span><span class="comment">equals</span><span class="comment">(</span><span class="comment">k</span><span class="comment">)), </span><span class="comment">then</span> <span class="comment">this</span> <span class="comment">method</span> <span class="comment">returns</span> <span class="comment">v</span><span class="comment">; </span><span class="comment">otherwise</span> <span class="comment">it</span> <span class="comment">returns</span> <span class="comment">null</span><span class="comment">.</span><span class="comment"> (</span><span class="comment">There</span> <span class="comment">can</span> <span class="comment">be</span> <span class="comment">at</span> <span class="comment">most</span> <span class="comment">one</span> <span class="comment">such</span> <span class="comment">mapping</span><span class="comment">.</span><span class="comment">)</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">If</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">permits</span> <span class="comment">null</span> <span class="comment">values</span><span class="comment">, </span><span class="comment">then</span> <span class="comment">a</span> <span class="comment">return</span> <span class="comment">value</span> <span class="comment">of</span> <span class="comment">null</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">necessarily</span> <span class="comment">indicate</span> <span class="comment">that</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">contains</span> <span class="comment">no</span> <span class="comment">mapping</span> <span class="comment">for</span> <span class="comment">the</span> <span class="comment">key</span><span class="comment">; </span><span class="comment">it</span><span class="comment">'</span><span class="comment">s</span> <span class="comment">also</span> <span class="comment">possible</span> <span class="comment">that</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">explicitly</span> <span class="comment">maps</span> <span class="comment">the</span> <span class="comment">key</span> <span class="comment">to</span> <span class="comment">null</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">containsKey</span> <span class="comment">operation</span> <span class="comment">may</span> <span class="comment">be</span> <span class="comment">used</span> <span class="comment">to</span> <span class="comment">distinguish</span> <span class="comment">these</span> <span class="comment">two</span> <span class="comment">cases</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">key</span><span class="comment"> - </span><span class="comment">the</span> <span class="comment">key</span> <span class="comment">whose</span> <span class="comment">associated</span> <span class="comment">value</span> <span class="comment">is</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">returned</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">to</span> <span class="comment">which</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">key</span> <span class="comment">is</span> <span class="comment">mapped</span><span class="comment">, </span><span class="comment">or</span> <span class="comment">null</span> <span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">contains</span> <span class="comment">no</span> <span class="comment">mapping</span> <span class="comment">for</span> <span class="comment">the</span> <span class="comment">key</span>
|
||||
<span class="comment"> * </span><span class="comment">@throws</span> <span class="comment">NullPointerException</span><span class="comment"> - </span><span class="comment">if</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">key</span> <span class="comment">is</span> <span class="comment">null</span> <span class="comment">and</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">permit</span> <span class="comment">null</span> <span class="comment">keys</span><span class="comment"> (</span><span class="comment">optional</span><span class="comment">)</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="comment">//done</span>
|
||||
@Override
|
||||
<span class="literal">public</span> V <span class="ST3">get</span>(Object key) {
|
||||
String dashes = <span class="string">"</span><span class="string">---------</span><span class="string">"</span>;
|
||||
<span class="literal">try</span> {
|
||||
System.<span class="ST5">out</span>.println(dashes + <span class="string">"</span><span class="string"> get(</span><span class="string">"</span> + key.toString() + <span class="string">"</span><span class="string">) </span><span class="string">"</span> + dashes);
|
||||
} <span class="literal">catch</span> (NullPointerException ex) {
|
||||
<span class="comment">//System.out.println(ex);</span>
|
||||
System.<span class="ST5">out</span>.println(dashes + <span class="string">"</span><span class="string"> get(</span><span class="string">"</span> + <span class="string">"</span><span class="string">null</span><span class="string">"</span> + <span class="string">"</span><span class="string">) </span><span class="string">"</span> + dashes);
|
||||
<span class="literal">throw</span> <span class="literal">new</span> NullPointerException(<span class="string">"</span><span class="string">null parameter</span><span class="string">"</span>);
|
||||
}
|
||||
Object currentKey = <span class="literal">null</span>;
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">map</span>.size(); ++i) {
|
||||
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="ST1">map</span>.get(i).size(); ++j) {
|
||||
currentKey = <span class="ST1">map</span>.get(i).get(j).<span class="ST1">key</span>;
|
||||
<span class="literal">if</span> (currentKey.equals(key)) {
|
||||
<span class="literal">return</span> <span class="ST1">map</span>.get(i).get(j).<span class="ST1">value</span>;
|
||||
}
|
||||
}
|
||||
}
|
||||
<span class="literal">return</span> <span class="literal">null</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Associates</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">value</span> <span class="comment">with</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">key</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span><span class="comment"> (</span><span class="comment">optional</span> <span class="comment">operation</span><span class="comment">)</span><span class="comment">.</span> <span class="comment">If</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">previously</span> <span class="comment">contained</span> <span class="comment">a</span> <span class="comment">mapping</span> <span class="comment">for</span> <span class="comment">the</span> <span class="comment">key</span><span class="comment">, </span><span class="comment">the</span> <span class="comment">old</span> <span class="comment">value</span> <span class="comment">is</span> <span class="comment">replaced</span> <span class="comment">by</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">value</span><span class="comment">.</span><span class="comment"> (</span><span class="comment">A</span> <span class="comment">map</span> <span class="comment">m</span> <span class="comment">is</span> <span class="comment">said</span> <span class="comment">to</span> <span class="comment">contain</span> <span class="comment">a</span> <span class="comment">mapping</span> <span class="comment">for</span> <span class="comment">a</span> <span class="comment">key</span> <span class="comment">k</span> <span class="comment">if</span> <span class="comment">and</span> <span class="comment">only</span> <span class="comment">if</span> <span class="comment">m</span><span class="comment">.</span><span class="comment">containsKey</span><span class="comment">(</span><span class="comment">k</span><span class="comment">) </span><span class="comment">would</span> <span class="comment">return</span> <span class="comment">true</span><span class="comment">.</span><span class="comment">)</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">key</span><span class="comment"> - </span><span class="comment">key</span> <span class="comment">with</span> <span class="comment">which</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">value</span> <span class="comment">is</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">associated</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">value</span><span class="comment"> - </span><span class="comment">value</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">associated</span> <span class="comment">with</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">key</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">the</span> <span class="comment">previous</span> <span class="comment">value</span> <span class="comment">associated</span> <span class="comment">with</span> <span class="comment">key</span><span class="comment">, </span><span class="comment">or</span> <span class="comment">null</span> <span class="comment">if</span> <span class="comment">there</span> <span class="comment">was</span> <span class="comment">no</span> <span class="comment">mapping</span> <span class="comment">for</span> <span class="comment">key</span><span class="comment">.</span><span class="comment"> (</span><span class="comment">A</span> <span class="comment">null</span> <span class="comment">return</span> <span class="comment">can</span> <span class="comment">also</span> <span class="comment">indicate</span> <span class="comment">that</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">previously</span> <span class="comment">associated</span> <span class="comment">null</span> <span class="comment">with</span> <span class="comment">key</span><span class="comment">, </span><span class="comment">if</span> <span class="comment">the</span> <span class="comment">implementation</span> <span class="comment">supports</span> <span class="comment">null</span> <span class="comment">values</span><span class="comment">.</span><span class="comment">)</span>
|
||||
<span class="comment"> * </span><span class="comment">@throws</span> <span class="comment">NullPointerException</span><span class="comment"> - </span><span class="comment">if</span> <span class="comment">specified</span> <span class="comment">key</span> <span class="comment">or</span> <span class="comment">value</span> <span class="comment">is</span> <span class="comment">null</span> <span class="comment">and</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">permit</span> <span class="comment">null</span> <span class="comment">keys</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> V <span class="ST3">put</span>(K key, V value) {
|
||||
|
||||
<span class="literal">if</span> (key == <span class="literal">null</span> || value == <span class="literal">null</span>) {
|
||||
<span class="literal">throw</span> <span class="literal">new</span> NullPointerException(<span class="string">"</span><span class="string">parm(s) null</span><span class="string">"</span>);
|
||||
}
|
||||
|
||||
<span class="comment">//>if contains the key, replace the key's value </span>
|
||||
EntryASDV<K, V> entry = getEntryForKey(key);
|
||||
<span class="literal">if</span> (entry != <span class="literal">null</span>) {
|
||||
V oldValue = entry.<span class="ST1">value</span>;
|
||||
entry.<span class="ST1">value</span> = value;
|
||||
|
||||
<span class="literal">return</span> oldValue;
|
||||
}
|
||||
<span class="comment">///>>hash and put in the array </span>
|
||||
<span class="literal">int</span> code = <span class="literal">this</span>.hash(key.hashCode());
|
||||
<span class="literal">int</span> index = hash(code);
|
||||
|
||||
ListASDV<EntryASDV<K, V>> list = <span class="ST1">map</span>.get(index);
|
||||
EntryASDV e = <span class="literal">new</span> EntryASDV(key, value);
|
||||
list.add(e);
|
||||
|
||||
<span class="comment">//>>add the key to the shared keys-set</span>
|
||||
((SharedSet<K>) <span class="literal">this</span>.<span class="ST1">sharedKeySet</span>).addEntry(key);
|
||||
((SharedSet<<span class="ST2">Entry</span><K, V>>) <span class="literal">this</span>.<span class="ST1">sharedEntrySet</span>).addEntry(e);
|
||||
|
||||
<span class="comment">//>>get the value of this entry</span>
|
||||
V v = list.get(list.size() - <span class="number">1</span>).getValue();
|
||||
|
||||
<span class="comment">//>> add value to the value collection</span>
|
||||
((SharedCollection<V>) <span class="literal">this</span>.<span class="ST1">sharedValuesCollection</span>).addValue(v);
|
||||
|
||||
<span class="comment">//>> if reach 75% capacity double the size</span>
|
||||
<span class="literal">if</span> ((<span class="literal">double</span>) <span class="literal">this</span>.size() / <span class="ST1">capacity</span> >= <span class="number">0.75</span>) {
|
||||
<span class="literal">this</span>.doubleTheSizeOfTheMapAndRehash();
|
||||
}
|
||||
|
||||
<span class="comment">//>>return the value of Entry just added</span>
|
||||
<span class="literal">return</span> v;
|
||||
}
|
||||
|
||||
<span class="literal">int</span> <span class="ST3">hash</span>(<span class="literal">int</span> keyHashCode) {
|
||||
<span class="literal">int</span> h = <span class="ST2">hashHash</span>(keyHashCode);
|
||||
<span class="literal">return</span> Math.<span class="ST2">abs</span>(h % <span class="ST1">capacity</span> - <span class="number">1</span>);
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Removes</span> <span class="comment">the</span> <span class="comment">first</span> <span class="comment">entry</span> <span class="comment">with</span> <span class="comment">the</span> <span class="comment">given</span> <span class="comment">values</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">value</span><span class="comment"> - </span><span class="comment">the</span> <span class="comment">value</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">removed</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">true</span> <span class="comment">if</span> <span class="comment">removed</span><span class="comment">, </span><span class="comment">false</span> <span class="comment">otherwise</span>
|
||||
<span class="comment"> * </span><span class="comment">@throws</span> <span class="comment">NullPointerException</span> <span class="comment">if</span> <span class="comment">the</span> <span class="comment">value</span> <span class="comment">is</span> <span class="comment">null</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">private</span> <span class="literal">boolean</span> <span class="ST3">removeFirstValue</span>(Object value) {
|
||||
Iterator<V> iterator = <span class="ST1">sharedValuesCollection</span>.iterator();
|
||||
<span class="literal">while</span> (iterator.hasNext()) {
|
||||
Object o = iterator.next();
|
||||
<span class="literal">if</span> (o.equals(value)) {
|
||||
iterator.remove();
|
||||
<span class="literal">return</span> <span class="literal">true</span>;
|
||||
}
|
||||
}
|
||||
<span class="literal">return</span> <span class="literal">false</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Ensure</span> <span class="comment">hash</span> <span class="comment">code</span> <span class="comment">is</span> <span class="comment">evenly</span> <span class="comment">distributed</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">h</span><span class="comment"> - </span><span class="comment">hash</span> <span class="comment">code</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">evenly</span> <span class="comment">distributed</span> <span class="comment">hash</span> <span class="comment">code</span>
|
||||
<span class="comment">*/</span>
|
||||
<span class="literal">private</span> <span class="literal">static</span> <span class="literal">int</span> <span class="ST6">hashHash</span>(<span class="literal">int</span> h) {
|
||||
h ^= (h >>> <span class="number">20</span>) ^ (h >>> <span class="number">12</span>);
|
||||
<span class="literal">return</span> h ^ (h >>> <span class="number">7</span>) ^ (h >>> <span class="number">4</span>);
|
||||
}
|
||||
|
||||
<span class="comment">// class cast helper method</span>
|
||||
<span class="literal">public</span> <span class="literal">static</span> <T> T <span class="ST6">cast</span>(Object o, Class<T> clazz) {
|
||||
<span class="literal">return</span> clazz.isInstance(o) ? clazz.cast(o) : <span class="literal">null</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Removes</span> <span class="comment">the</span> <span class="comment">mapping</span> <span class="comment">for</span> <span class="comment">a</span> <span class="comment">key</span> <span class="comment">from</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">if</span> <span class="comment">it</span> <span class="comment">is</span> <span class="comment">present</span><span class="comment"> (</span><span class="comment">optional</span> <span class="comment">operation</span><span class="comment">)</span><span class="comment">.</span> <span class="comment">More</span> <span class="comment">formally</span><span class="comment">, </span><span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">contains</span> <span class="comment">a</span> <span class="comment">mapping</span> <span class="comment">from</span> <span class="comment">key</span> <span class="comment">k</span> <span class="comment">to</span> <span class="comment">value</span> <span class="comment">v</span> <span class="comment">such</span> <span class="comment">that</span><span class="comment"> (</span><span class="comment">key</span><span class="comment">==</span><span class="comment">null</span><span class="comment"> ? </span><span class="comment">k</span><span class="comment">==</span><span class="comment">null</span><span class="comment"> : </span><span class="comment">key</span><span class="comment">.</span><span class="comment">equals</span><span class="comment">(</span><span class="comment">k</span><span class="comment">)), </span><span class="comment">that</span> <span class="comment">mapping</span> <span class="comment">is</span> <span class="comment">removed</span><span class="comment">.</span><span class="comment"> (</span><span class="comment">The</span> <span class="comment">map</span> <span class="comment">can</span> <span class="comment">contain</span> <span class="comment">at</span> <span class="comment">most</span> <span class="comment">one</span> <span class="comment">such</span> <span class="comment">mapping</span><span class="comment">.</span><span class="comment">)</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">key</span><span class="comment"> - </span><span class="comment">key</span> <span class="comment">whose</span> <span class="comment">mapping</span> <span class="comment">is</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">removed</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">map</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">the</span> <span class="comment">previous</span> <span class="comment">value</span> <span class="comment">associated</span> <span class="comment">with</span> <span class="comment">key</span><span class="comment">, </span><span class="comment">or</span> <span class="comment">null</span> <span class="comment">if</span> <span class="comment">there</span> <span class="comment">was</span> <span class="comment">no</span> <span class="comment">mapping</span> <span class="comment">for</span> <span class="comment">key</span><span class="comment">.</span>
|
||||
<span class="comment"> * </span><span class="comment">@throws</span> <span class="comment">NullPointerException</span><span class="comment"> - </span><span class="comment">if</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">key</span> <span class="comment">is</span> <span class="comment">null</span> <span class="comment">and</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">permit</span> <span class="comment">null</span> <span class="comment">keys</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> V <span class="ST3">remove</span>(Object key) {
|
||||
String dashes = <span class="string">"</span><span class="string">---------</span><span class="string">"</span>;
|
||||
<span class="literal">try</span> {
|
||||
System.<span class="ST5">out</span>.println(dashes + <span class="string">"</span><span class="string"> remove(</span><span class="string">"</span> + key.toString() + <span class="string">"</span><span class="string">) </span><span class="string">"</span> + dashes);
|
||||
} <span class="literal">catch</span> (NullPointerException ex) {
|
||||
System.<span class="ST5">out</span>.println(ex);
|
||||
System.<span class="ST5">out</span>.println(dashes + <span class="string">"</span><span class="string"> remove(</span><span class="string">"</span> + <span class="string">"</span><span class="string">null</span><span class="string">"</span> + <span class="string">"</span><span class="string">) </span><span class="string">"</span> + dashes);
|
||||
<span class="literal">throw</span> <span class="literal">new</span> NullPointerException(<span class="string">"</span><span class="string">null parameter</span><span class="string">"</span>);
|
||||
}
|
||||
K currentKey = <span class="literal">null</span>;
|
||||
V currentValue = <span class="literal">null</span>;
|
||||
EntryASDV<K, V> currentEntry = <span class="literal">null</span>;
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">map</span>.size(); ++i) {
|
||||
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="ST1">map</span>.get(i).size(); ++j) {
|
||||
currentEntry = <span class="ST1">map</span>.get(i).get(j);
|
||||
currentKey = currentEntry.<span class="ST1">key</span>;
|
||||
currentValue = currentEntry.<span class="ST1">value</span>;
|
||||
<span class="literal">if</span> (currentKey.equals(key) || currentValue.equals(key)) {
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">key: </span><span class="string">"</span> + currentKey + <span class="string">"</span><span class="string">; value: </span><span class="string">"</span> + currentValue);
|
||||
<span class="comment">// remove the entry from the map</span>
|
||||
<span class="ST1">map</span>.remove(i);
|
||||
<span class="comment">// remove the key from the shared key set</span>
|
||||
<span class="comment">// duplicate the set so we can iterate through it and not throw a ConcurrentModificationException...</span>
|
||||
Object[] iterateArray = <span class="ST1">sharedKeySet</span>.toArray();
|
||||
<span class="literal">for</span> (Object o : iterateArray) {
|
||||
<span class="literal">if</span> (o.equals(currentKey)) {
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">removing </span><span class="string">"</span> + o);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">remove successful? </span><span class="string">"</span> + <span class="ST1">sharedKeySet</span>.remove(currentKey));
|
||||
<span class="literal">break</span>; <span class="comment">// we only want to delete the first one</span>
|
||||
}
|
||||
}
|
||||
<span class="comment">// remove the value from the shared key map</span>
|
||||
<span class="comment">// duplicate again...</span>
|
||||
iterateArray = <span class="ST1">sharedEntrySet</span>.toArray();
|
||||
<span class="literal">for</span> (Object o : iterateArray) {
|
||||
<span class="literal">if</span> (o.equals(currentEntry)) {
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">removing </span><span class="string">"</span> + o);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">remove successful? </span><span class="string">"</span> + <span class="ST1">sharedEntrySet</span>.remove(currentEntry));
|
||||
<span class="literal">break</span>; <span class="comment">// we only want to delete the first one</span>
|
||||
}
|
||||
}
|
||||
<span class="comment">// Finally, remove the value from sharedValuesCollection</span>
|
||||
<span class="comment">// duplicate again...</span>
|
||||
iterateArray = <span class="ST1">sharedValuesCollection</span>.toArray();
|
||||
<span class="literal">for</span> (Object o : iterateArray) {
|
||||
<span class="comment">//System.out.println(o);</span>
|
||||
<span class="literal">if</span> (o.equals(currentValue)) {
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">removing </span><span class="string">"</span> + o);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">remove successful? </span><span class="string">"</span> + <span class="ST1">sharedValuesCollection</span>.remove(o));
|
||||
<span class="literal">break</span>; <span class="comment">// we only want to delete the first one</span>
|
||||
}
|
||||
}
|
||||
<span class="comment">//for(Object o: sharedValuesCollection.toArray()) System.out.println(o); </span>
|
||||
<span class="literal">return</span> currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
<span class="literal">return</span> <span class="literal">null</span>;
|
||||
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Copies</span> <span class="comment">all</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">mappings</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">map</span> <span class="comment">to</span> <span class="comment">this</span> <span class="comment">map</span><span class="comment"> (</span><span class="comment">optional</span> <span class="comment">operation</span><span class="comment">)</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">effect</span> <span class="comment">of</span> <span class="comment">this</span> <span class="comment">call</span> <span class="comment">is</span> <span class="comment">equivalent</span> <span class="comment">to</span> <span class="comment">that</span> <span class="comment">of</span> <span class="comment">calling</span> <span class="comment">put</span><span class="comment">(</span><span class="comment">k</span><span class="comment">, </span><span class="comment">v</span><span class="comment">) </span><span class="comment">on</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">once</span> <span class="comment">for</span> <span class="comment">each</span> <span class="comment">mapping</span> <span class="comment">from</span> <span class="comment">key</span> <span class="comment">k</span> <span class="comment">to</span> <span class="comment">value</span> <span class="comment">v</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">map</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">behavior</span> <span class="comment">of</span> <span class="comment">this</span> <span class="comment">operation</span> <span class="comment">is</span> <span class="comment">undefined</span> <span class="comment">if</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">map</span> <span class="comment">is</span> <span class="comment">modified</span> <span class="comment">while</span> <span class="comment">the</span> <span class="comment">operation</span> <span class="comment">is</span> <span class="comment">in</span> <span class="comment">progress</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@param</span> <span class="ST4">m</span><span class="comment"> - </span><span class="comment">mappings</span> <span class="comment">to</span> <span class="comment">be</span> <span class="comment">stored</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span>
|
||||
<span class="comment"> * </span><span class="comment">@throws</span> <span class="comment">NullPointerException</span><span class="comment"> - </span><span class="comment">if</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">map</span> <span class="comment">is</span> <span class="comment">null</span><span class="comment">, </span><span class="comment">or</span> <span class="comment">if</span> <span class="comment">this</span> <span class="comment">map</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">permit</span> <span class="comment">null</span> <span class="comment">keys</span> <span class="comment">or</span> <span class="comment">values</span><span class="comment">, </span><span class="comment">and</span> <span class="comment">the</span> <span class="comment">specified</span> <span class="comment">map</span> <span class="comment">contains</span> <span class="comment">null</span> <span class="comment">keys</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">putAll</span>(Map<? <span class="literal">extends</span> K, ? <span class="literal">extends</span> V> m) {
|
||||
<span class="literal">if</span> (m == <span class="literal">null</span>) {
|
||||
<span class="literal">throw</span> <span class="literal">new</span> NullPointerException(<span class="string">"</span><span class="string">null parameter</span><span class="string">"</span>);
|
||||
}
|
||||
|
||||
BiConsumer consumeEachEntry = <span class="literal">new</span> BiConsumer<K, V>() {
|
||||
MapASDV<K, V> <span class="ST1">mapForConsumer</span> = MapASDV.<span class="literal">this</span>;
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">accept</span>(K k, V v) {
|
||||
<span class="ST1">mapForConsumer</span>.put(k, v);
|
||||
}
|
||||
};
|
||||
|
||||
m.forEach(consumeEachEntry);
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Removes</span> <span class="comment">all</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">mappings</span> <span class="comment">from</span> <span class="comment">this</span> <span class="comment">map</span><span class="comment"> (</span><span class="comment">optional</span> <span class="comment">operation</span><span class="comment">)</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">map</span> <span class="comment">will</span> <span class="comment">be</span> <span class="comment">empty</span> <span class="comment">after</span> <span class="comment">this</span> <span class="comment">call</span> <span class="comment">returns</span><span class="comment">.</span> <span class="comment">Any</span> <span class="comment">shared</span> <span class="comment">sets</span> <span class="comment">are</span> <span class="comment">also</span> <span class="comment">cleared</span><span class="comment">.</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> <span class="literal">void</span> <span class="ST3">clear</span>() {
|
||||
|
||||
<span class="comment">// Clear everything out by redefining all internal values, and let Java's GC take care of the rest</span>
|
||||
<span class="ST1">map</span> = <span class="literal">new</span> ArrayList<>();
|
||||
<span class="ST1">sharedKeySet</span> = <span class="literal">new</span> SharedSet<K>();
|
||||
<span class="ST1">sharedEntrySet</span> = <span class="literal">new</span> SharedSet<<span class="ST2">Entry</span><K, V>>();
|
||||
<span class="ST1">sharedValuesCollection</span> = <span class="literal">new</span> SharedCollection<V>();
|
||||
<span class="comment">//capacity = 4;</span>
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">capacity</span>; ++i) {
|
||||
<span class="ST1">map</span>.add(<span class="literal">new</span> ListASDV<EntryASDV<K, V>>());
|
||||
}
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Returns</span> <span class="comment">a</span> <span class="comment">Set</span> <span class="comment">view</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">keys</span> <span class="comment">contained</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">set</span> <span class="comment">is</span> <span class="comment">backed</span> <span class="comment">by</span> <span class="comment">the</span> <span class="comment">map</span><span class="comment">, </span><span class="comment">so</span> <span class="comment">changes</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">are</span> <span class="comment">reflected</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">set</span><span class="comment">, </span><span class="comment">and</span> <span class="comment">vice</span><span class="comment">-</span><span class="comment">versa</span><span class="comment">.</span> <span class="comment">If</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">is</span> <span class="comment">modified</span> <span class="comment">while</span> <span class="comment">an</span> <span class="comment">iteration</span> <span class="comment">over</span> <span class="comment">the</span> <span class="comment">set</span> <span class="comment">is</span> <span class="comment">in</span> <span class="comment">progress</span><span class="comment"> (</span><span class="comment">except</span> <span class="comment">through</span> <span class="comment">the</span> <span class="comment">iterator</span><span class="comment">'</span><span class="comment">s</span> <span class="comment">own</span> <span class="comment">remove</span> <span class="comment">operation</span><span class="comment">), </span><span class="comment">the</span> <span class="comment">results</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">iteration</span> <span class="comment">are</span> <span class="comment">undefined</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">set</span> <span class="comment">supports</span> <span class="comment">element</span> <span class="comment">removal</span><span class="comment">, </span><span class="comment">which</span> <span class="comment">removes</span> <span class="comment">the</span> <span class="comment">corresponding</span> <span class="comment">mapping</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">map</span><span class="comment">, </span><span class="comment">via</span> <span class="comment">the</span> <span class="comment">Iterator</span><span class="comment">.</span><span class="comment">remove</span><span class="comment">, </span><span class="comment">Set</span><span class="comment">.</span><span class="comment">remove</span><span class="comment">, </span><span class="comment">removeAll</span><span class="comment">, </span><span class="comment">retainAll</span><span class="comment">, </span><span class="comment">and</span> <span class="comment">clear</span> <span class="comment">operations</span><span class="comment">.</span> <span class="comment">It</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">support</span> <span class="comment">the</span> <span class="comment">add</span> <span class="comment">or</span> <span class="comment">addAll</span> <span class="comment">operations</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">a</span> <span class="comment">set</span> <span class="comment">view</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">keys</span> <span class="comment">contained</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> Set<K> <span class="ST3">keySet</span>() {
|
||||
|
||||
<span class="literal">return</span> <span class="literal">this</span>.<span class="ST1">sharedKeySet</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Returns</span> <span class="comment">a</span> <span class="comment">Collection</span> <span class="comment">view</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">values</span> <span class="comment">contained</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">collection</span> <span class="comment">is</span> <span class="comment">backed</span> <span class="comment">by</span> <span class="comment">the</span> <span class="comment">map</span><span class="comment">, </span><span class="comment">so</span> <span class="comment">changes</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">are</span> <span class="comment">reflected</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">collection</span><span class="comment">, </span><span class="comment">and</span> <span class="comment">vice</span><span class="comment">-</span><span class="comment">versa</span><span class="comment">.</span> <span class="comment">If</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">is</span> <span class="comment">modified</span> <span class="comment">while</span> <span class="comment">an</span> <span class="comment">iteration</span> <span class="comment">over</span> <span class="comment">the</span> <span class="comment">collection</span> <span class="comment">is</span> <span class="comment">in</span> <span class="comment">progress</span><span class="comment"> (</span><span class="comment">except</span> <span class="comment">through</span> <span class="comment">the</span> <span class="comment">iterator</span><span class="comment">'</span><span class="comment">s</span> <span class="comment">own</span> <span class="comment">remove</span> <span class="comment">operation</span><span class="comment">), </span><span class="comment">the</span> <span class="comment">results</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">iteration</span> <span class="comment">are</span> <span class="comment">undefined</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">collection</span> <span class="comment">supports</span> <span class="comment">element</span> <span class="comment">removal</span><span class="comment">, </span><span class="comment">which</span> <span class="comment">removes</span> <span class="comment">the</span> <span class="comment">corresponding</span> <span class="comment">mapping</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">map</span><span class="comment">, </span><span class="comment">via</span> <span class="comment">the</span> <span class="comment">Iterator</span><span class="comment">.</span><span class="comment">remove</span><span class="comment">, </span><span class="comment">Collection</span><span class="comment">.</span><span class="comment">remove</span><span class="comment">, </span><span class="comment">removeAll</span><span class="comment">, </span><span class="comment">retainAll</span> <span class="comment">and</span> <span class="comment">clear</span> <span class="comment">operations</span><span class="comment">.</span> <span class="comment">It</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">support</span> <span class="comment">the</span> <span class="comment">add</span> <span class="comment">or</span> <span class="comment">addAll</span> <span class="comment">operations</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> Collection<V> <span class="ST3">values</span>() {
|
||||
<span class="literal">return</span> <span class="ST1">sharedValuesCollection</span>;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Returns</span> <span class="comment">a</span> <span class="comment">Set</span> <span class="comment">view</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">mappings</span> <span class="comment">contained</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">set</span> <span class="comment">is</span> <span class="comment">backed</span> <span class="comment">by</span> <span class="comment">the</span> <span class="comment">map</span><span class="comment">, </span><span class="comment">so</span> <span class="comment">changes</span> <span class="comment">to</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">are</span> <span class="comment">reflected</span> <span class="comment">in</span> <span class="comment">the</span> <span class="comment">set</span><span class="comment">, </span><span class="comment">and</span> <span class="comment">vice</span><span class="comment">-</span><span class="comment">versa</span><span class="comment">.</span> <span class="comment">If</span> <span class="comment">the</span> <span class="comment">map</span> <span class="comment">is</span> <span class="comment">modified</span> <span class="comment">while</span> <span class="comment">an</span> <span class="comment">iteration</span> <span class="comment">over</span> <span class="comment">the</span> <span class="comment">set</span> <span class="comment">is</span> <span class="comment">in</span> <span class="comment">progress</span><span class="comment"> (</span><span class="comment">except</span> <span class="comment">through</span> <span class="comment">the</span> <span class="comment">iterator</span><span class="comment">'</span><span class="comment">s</span> <span class="comment">own</span> <span class="comment">remove</span> <span class="comment">operation</span><span class="comment">, </span><span class="comment">or</span> <span class="comment">through</span> <span class="comment">the</span> <span class="comment">setValue</span> <span class="comment">operation</span> <span class="comment">on</span> <span class="comment">a</span> <span class="comment">map</span> <span class="comment">entry</span> <span class="comment">returned</span> <span class="comment">by</span> <span class="comment">the</span> <span class="comment">iterator</span><span class="comment">) </span><span class="comment">the</span> <span class="comment">results</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">iteration</span> <span class="comment">are</span> <span class="comment">undefined</span><span class="comment">.</span> <span class="comment">The</span> <span class="comment">set</span> <span class="comment">supports</span> <span class="comment">element</span> <span class="comment">removal</span><span class="comment">, </span><span class="comment">which</span> <span class="comment">removes</span> <span class="comment">the</span> <span class="comment">corresponding</span> <span class="comment">mapping</span> <span class="comment">from</span> <span class="comment">the</span> <span class="comment">map</span><span class="comment">, </span><span class="comment">via</span> <span class="comment">the</span> <span class="comment">Iterator</span><span class="comment">.</span><span class="comment">remove</span><span class="comment">, </span><span class="comment">Set</span><span class="comment">.</span><span class="comment">remove</span><span class="comment">, </span><span class="comment">removeAll</span><span class="comment">, </span><span class="comment">retainAll</span> <span class="comment">and</span> <span class="comment">clear</span> <span class="comment">operations</span><span class="comment">.</span> <span class="comment">It</span> <span class="comment">does</span> <span class="comment">not</span> <span class="comment">support</span> <span class="comment">the</span> <span class="comment">add</span> <span class="comment">or</span> <span class="comment">addAll</span> <span class="comment">operations</span><span class="comment">.</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">a</span> <span class="comment">set</span> <span class="comment">view</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">mappings</span> <span class="comment">contained</span> <span class="comment">in</span> <span class="comment">this</span> <span class="comment">map</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> Set<<span class="ST2">Entry</span><K, V>> <span class="ST3">entrySet</span>() {
|
||||
<span class="literal">return</span> <span class="literal">this</span>.<span class="ST1">sharedEntrySet</span>;
|
||||
}
|
||||
|
||||
@Override
|
||||
<span class="literal">public</span> String <span class="ST3">toString</span>() {
|
||||
String s = <span class="string">"</span><span class="string">[ </span><span class="string">"</span>;
|
||||
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < <span class="ST1">map</span>.size(); ++i) {
|
||||
s += <span class="ST1">map</span>.get(i).toString() + <span class="string">"</span><span class="literal">\n</span><span class="string">"</span>;
|
||||
}
|
||||
s += <span class="string">"</span><span class="string"> ]</span><span class="string">"</span>;
|
||||
|
||||
<span class="literal">return</span> s;
|
||||
}
|
||||
|
||||
<span class="comment">/**</span>
|
||||
<span class="comment"> * </span><span class="comment">Created</span> <span class="comment">a</span> <span class="comment">deep</span> <span class="comment">copy</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">MapASDV</span>
|
||||
<span class="comment"> *</span>
|
||||
<span class="comment"> * </span><span class="comment">@return</span> <span class="comment">the</span> <span class="comment">deep</span> <span class="comment">copy</span> <span class="comment">of</span> <span class="comment">the</span> <span class="comment">map</span>
|
||||
<span class="comment">*/</span>
|
||||
@Override
|
||||
<span class="literal">public</span> Object <span class="ST3">clone</span>() {
|
||||
<span class="comment">/*</span>
|
||||
<span class="comment"> MapASDV<K, V> clonedMap = new MapASDV<K, V>();</span>
|
||||
|
||||
<span class="comment"> //clonedMap.putAll(this);</span>
|
||||
|
||||
<span class="comment"> for (ListASDV< EntryASDV<K, V>> list : this.map)</span>
|
||||
<span class="comment"> {</span>
|
||||
<span class="comment"> ListASDV< EntryASDV<K, V>> l = (ListASDV< EntryASDV<K, V>>) list.clone();</span>
|
||||
<span class="comment"> clonedMap.map.add(l); </span>
|
||||
<span class="comment"> }</span>
|
||||
<span class="comment"> return clonedMap;</span>
|
||||
<span class="comment"> */</span>
|
||||
|
||||
MapASDV<K, V> clonedMap = <span class="literal">new</span> MapASDV<K, V>();
|
||||
clonedMap.putAll(<span class="literal">t</span><span class="literal">his</span>);
|
||||
<span class="literal">return</span> clonedMap;
|
||||
}
|
||||
|
||||
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST6">main</span>(String[] args) {
|
||||
|
||||
MapASDV<String, Integer> map = <span class="literal">new</span> MapASDV<>();
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">---------------------------testing put(K, V)</span><span class="string">"</span>);
|
||||
map.put(<span class="string">"</span><span class="string">ann</span><span class="string">"</span>, <span class="number">2</span><span class="number">0</span>);
|
||||
map.put(<span class="string">"</span><span class="string">coco</span><span class="string">"</span>, <span class="number">2</span><span class="number">5</span>);
|
||||
System.<span class="ST5">out</span>.println(map);
|
||||
MapASDV<String, Integer> clonedMap = (MapASDV<String, Integer>) map.clone();
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing double-the-size-and-rehash by reaching 0.75 load factor with another put(K, V)</span><span class="string">"</span>);
|
||||
map.put(<span class="string">"</span><span class="string">Jonathan</span><span class="string">"</span>, <span class="number">3</span><span class="number">0</span>);
|
||||
System.<span class="ST5">out</span>.println(map);
|
||||
map.put(<span class="string">"</span><span class="string">Jonhathan</span><span class="string">"</span>, <span class="number">4</span><span class="number">5</span>);
|
||||
System.<span class="ST5">out</span>.println(map);
|
||||
map.put(<span class="string">"</span><span class="string">Alexander</span><span class="string">"</span>, <span class="number">3</span><span class="number">3</span>);
|
||||
System.<span class="ST5">out</span>.println(map);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing putAll(Map<K,V>)</span><span class="string">"</span>);
|
||||
Map<String, Integer> anotherJavaMap = <span class="literal">new</span> HashMap();
|
||||
anotherJavaMap.put(<span class="string">"</span><span class="string">lion king</span><span class="string">"</span>, <span class="number">4</span><span class="number">5</span>);
|
||||
anotherJavaMap.put(<span class="string">"</span><span class="string">HYENA</span><span class="string">"</span>, <span class="number">6</span>);
|
||||
map.putAll(anotherJavaMap);
|
||||
System.<span class="ST5">out</span>.println(map);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing containsKey</span><span class="string">"</span>);
|
||||
System.<span class="ST5">out</span>.println(map.containsKey(<span class="string">"</span><span class="string">Alexander</span><span class="string">"</span>));
|
||||
System.<span class="ST5">out</span>.println(map.containsKey(<span class="string">"</span><span class="string">alexander</span><span class="string">"</span>));
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing containsValue</span><span class="string">"</span>);
|
||||
System.<span class="ST5">out</span>.println(map.containsValue(<span class="number">3</span><span class="number">3</span>));
|
||||
System.<span class="ST5">out</span>.println(map.containsValue(<span class="number">3</span><span class="number">4</span>));
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing getEntryForKey</span><span class="string">"</span>);
|
||||
<span class="ST2">Entry</span><String, Integer> e = map.getEntryForKey(<span class="string">"</span><span class="string">Alexander</span><span class="string">"</span>);
|
||||
System.<span class="ST5">out</span>.println(map.getEntryForKey(<span class="string">"</span><span class="string">Alexander</span><span class="string">"</span>));
|
||||
System.<span class="ST5">out</span>.println(map.getEntryForKey(<span class="string">"</span><span class="string">Alex</span><span class="string">"</span>));
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing get</span><span class="string">"</span>);
|
||||
System.<span class="ST5">out</span>.println(map.get(<span class="string">"</span><span class="string">Alexander</span><span class="string">"</span>));
|
||||
System.<span class="ST5">out</span>.println(map.get(<span class="string">"</span><span class="string">Alex</span><span class="string">"</span>));
|
||||
<span class="literal">try</span> {
|
||||
map.get(<span class="literal">n</span><span class="literal">ull</span>);
|
||||
} <span class="literal">catch</span> (NullPointerException ex) {
|
||||
System.<span class="ST5">out</span>.println(ex.getMessage());
|
||||
}
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing getIndexForKey</span><span class="string">"</span>);
|
||||
System.<span class="ST5">out</span>.println(map.getIndexForKey(<span class="string">"</span><span class="string">Alexander</span><span class="string">"</span>));
|
||||
System.<span class="ST5">out</span>.println(map.getIndexForKey(<span class="string">"</span><span class="string">Alex</span><span class="string">"</span>));
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing isEmpty</span><span class="string">"</span>);
|
||||
System.<span class="ST5">out</span>.println(map.isEmpty());
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing size</span><span class="string">"</span>);
|
||||
System.<span class="ST5">out</span>.println(map.size());
|
||||
System.<span class="ST5">out</span>.println(map);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing entrySet()</span><span class="string">"</span>);
|
||||
Set<<span class="ST2">Entry</span><String, Integer>> entries = map.entrySet();
|
||||
System.<span class="ST5">out</span>.println(entries);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing keySet()</span><span class="string">"</span>);
|
||||
Set<String> keys = map.keySet();
|
||||
System.<span class="ST5">out</span>.println(keys);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing values()</span><span class="string">"</span>);
|
||||
Collection<Integer> values = map.values();
|
||||
System.<span class="ST5">out</span>.println(values);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing remove( K) coco 25</span><span class="string">"</span>);
|
||||
map.remove(<span class="string">"</span><span class="string">coco</span><span class="string">"</span>);
|
||||
values = map.values();
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">map: </span><span class="string">"</span> + map);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">entries: </span><span class="string">"</span> + entries);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">keys: </span><span class="string">"</span> + keys);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">values: </span><span class="string">"</span> + values);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing Entry-Collection remove </span><span class="string">"</span>);
|
||||
entries.remove(e);
|
||||
values = map.values();
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">map: </span><span class="string">"</span> + map);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">entries: </span><span class="string">"</span> + entries);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">keys: </span><span class="string">"</span> + keys);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">values: </span><span class="string">"</span> + values);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing Set Keys remove </span><span class="string">"</span>);
|
||||
keys.remove(<span class="string">"</span><span class="string">ann</span><span class="string">"</span>);
|
||||
values = map.values();
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">map: </span><span class="string">"</span> + map);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">entries: </span><span class="string">"</span> + entries);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">keys: </span><span class="string">"</span> + keys);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">values: </span><span class="string">"</span> + values);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing Set Values remove </span><span class="string">"</span>);
|
||||
values.remove(<span class="number">4</span><span class="number">5</span>);
|
||||
values = map.values();
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">map: </span><span class="string">"</span> + map);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">entries: </span><span class="string">"</span> + entries);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">keys: </span><span class="string">"</span> + keys);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">values: </span><span class="string">"</span> + values);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing clear </span><span class="string">"</span>);
|
||||
map.clear();
|
||||
values = map.values();
|
||||
entries = map.entrySet();
|
||||
keys = map.keySet();
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">map: </span><span class="string">"</span> + map);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">entries: </span><span class="string">"</span> + entries);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">keys: </span><span class="string">"</span> + keys);
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">values: </span><span class="string">"</span> + values);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing add of sets and collections </span><span class="string">"</span>);
|
||||
<span class="literal">try</span> {
|
||||
keys.add(<span class="string">"</span><span class="string">a</span><span class="string">"</span>);
|
||||
} <span class="literal">catch</span> (Exception ex) {
|
||||
System.<span class="ST5">out</span>.println(ex.getMessage());
|
||||
}
|
||||
<span class="literal">try</span> {
|
||||
values.add(<span class="number">3</span><span class="number">3</span>);
|
||||
} <span class="literal">catch</span> (Exception ex) {
|
||||
System.<span class="ST5">out</span>.println(ex.getMessage());
|
||||
}
|
||||
<span class="literal">try</span> {
|
||||
entries.add(e);
|
||||
} <span class="literal">catch</span> (Exception ex) {
|
||||
System.<span class="ST5">out</span>.println(ex.getMessage());
|
||||
}
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="literal">\n</span><span class="string">---------------------------testing clone</span><span class="string">"</span>);
|
||||
System.<span class="ST5">out</span>.println(clonedMap);
|
||||
|
||||
System.<span class="ST5">out</span>.println(<span class="string">"</span><span class="string">---------------------------testing put(K, V) AGAIN</span><span class="string">"</span>);
|
||||
map.put(<span class="string">"</span><span class="string">Nicholas</span><span class="string">"</span>, <span class="number">1</span><span class="number">00</span>);
|
||||
map.put(<span class="string">"</span><span class="string">a</span><span class="string">"</span>, <span class="number">2</span><span class="number">00</span>);
|
||||
map.put(<span class="string">"</span><span class="string">b</span><span class="string">"</span>, -<span class="number">20</span>);
|
||||
System.<span class="ST5">out</span>.println(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</pre></body>
|
||||
</html>
|
@ -71,7 +71,7 @@ jlink.additionalmodules=
|
||||
jlink.additionalparam=
|
||||
jlink.launcher=true
|
||||
jlink.launcher.name=MapASDV_CalebFontenot
|
||||
main.class=mapasdv_calebfontenot.MapASDV_CalebFontenot
|
||||
main.class=mapasdv_calebfontenot.MapASDV
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
|
Binary file not shown.
@ -1330,7 +1330,7 @@ public class ListASDV<E>
|
||||
s += '}';
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
public static void main(String[] args)
|
||||
{
|
||||
class ASDV_ENTRY<T1, T2> implements Map.Entry<T1, T1>
|
||||
@ -1685,6 +1685,7 @@ public class ListASDV<E>
|
||||
}
|
||||
|
||||
}
|
||||
**/
|
||||
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
BIN
Semester 4/ZIPs/MapASDV_CalebFontenot.zip
Normal file
BIN
Semester 4/ZIPs/MapASDV_CalebFontenot.zip
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user