Skip to content

Commit 19a97b7

Browse files
Fixed LRUCache error
1 parent 41d8559 commit 19a97b7

File tree

5 files changed

+51
-24
lines changed

5 files changed

+51
-24
lines changed

LinkedList/LRUCache/src/lrucache/DoublyLinkedList.java

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public void setHead(DoublyLinkedListNode node) {
3333
removeTail();
3434
}
3535

36+
node.removeBindings();
3637
head.prev = node;
3738
node.next = head;
3839
head = node;

LinkedList/LRUCache/src/lrucache/DoublyLinkedListNode.java

+13
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,17 @@ public DoublyLinkedListNode(String key, int value) {
2020
this.value = value;
2121
this.key = key;
2222
}
23+
24+
public void removeBindings() {
25+
if (prev != null) {
26+
prev.next = next;
27+
}
28+
29+
if (next != null) {
30+
next.prev = prev;
31+
}
32+
33+
prev = null;
34+
next = null;
35+
}
2336
}

LinkedList/LRUCache/src/lrucache/Main.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public static void main(String[] args) {
2929
lruCache.getValueFromKey("c");
3030
lruCache.getValueFromKey("d");
3131
lruCache.insertKeyValuePair("g", 5);
32-
System.out.println(lruCache.getValueFromKey("e").value);
33-
System.out.println(lruCache.getValueFromKey("a").value);
32+
lruCache.insertKeyValuePair("a", 2);
33+
System.out.println(lruCache.mostRecentList.head.value);
3434
}
3535

3636
}

LinkedList/ReverseSinglyLinkedList/nbproject/build-impl.xml

+33-20
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ is divided into following sections:
4646
<property file="${user.properties.file}"/>
4747
<!-- The two properties below are usually overridden -->
4848
<!-- by the active platform. Just a fallback. -->
49-
<property name="default.javac.source" value="1.4"/>
50-
<property name="default.javac.target" value="1.4"/>
49+
<property name="default.javac.source" value="1.6"/>
50+
<property name="default.javac.target" value="1.6"/>
5151
</target>
5252
<target depends="-pre-init,-init-private,-init-user" name="-init-project">
5353
<property file="nbproject/configs/${config}.properties"/>
@@ -76,13 +76,16 @@ is divided into following sections:
7676
<and>
7777
<isset property="javac.profile"/>
7878
<length length="0" string="${javac.profile}" when="greater"/>
79-
<matches pattern="1\.[89](\..*)?" string="${javac.source}"/>
79+
<matches pattern="((1\.[89])|9)(\..*)?" string="${javac.source}"/>
8080
</and>
8181
</condition>
8282
<condition property="do.archive">
83-
<not>
84-
<istrue value="${jar.archive.disabled}"/>
85-
</not>
83+
<or>
84+
<not>
85+
<istrue value="${jar.archive.disabled}"/>
86+
</not>
87+
<istrue value="${not.archive.disabled}"/>
88+
</or>
8689
</condition>
8790
<condition property="do.mkdist">
8891
<and>
@@ -153,6 +156,7 @@ is divided into following sections:
153156
<property name="application.args" value=""/>
154157
<property name="source.encoding" value="${file.encoding}"/>
155158
<property name="runtime.encoding" value="${source.encoding}"/>
159+
<property name="manifest.encoding" value="${source.encoding}"/>
156160
<condition property="javadoc.encoding.used" value="${javadoc.encoding}">
157161
<and>
158162
<isset property="javadoc.encoding"/>
@@ -188,7 +192,12 @@ is divided into following sections:
188192
</not>
189193
</and>
190194
</condition>
191-
<property name="javac.fork" value="${jdkBug6558476}"/>
195+
<condition else="false" property="javac.fork">
196+
<or>
197+
<istrue value="${jdkBug6558476}"/>
198+
<istrue value="${javac.external.vm}"/>
199+
</or>
200+
</condition>
192201
<property name="jar.index" value="false"/>
193202
<property name="jar.index.metainf" value="${jar.index}"/>
194203
<property name="copylibs.rebase" value="true"/>
@@ -214,6 +223,7 @@ is divided into following sections:
214223
<condition else="" property="testng.debug.mode" value="-mixed">
215224
<istrue value="${junit+testng.available}"/>
216225
</condition>
226+
<property name="java.failonerror" value="true"/>
217227
</target>
218228
<target name="-post-init">
219229
<!-- Empty placeholder for easier customization. -->
@@ -690,7 +700,7 @@ is divided into following sections:
690700
<sequential>
691701
<property environment="env"/>
692702
<resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
693-
<java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
703+
<java classname="@{classname}" dir="${profiler.info.dir}" failonerror="${java.failonerror}" fork="true" jvm="${profiler.info.jvm}">
694704
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
695705
<jvmarg value="${profiler.info.jvmargs.agent}"/>
696706
<jvmarg line="${profiler.info.jvmargs}"/>
@@ -765,7 +775,7 @@ is divided into following sections:
765775
<attribute default="${debug.classpath}" name="classpath"/>
766776
<element name="customize" optional="true"/>
767777
<sequential>
768-
<java classname="@{classname}" dir="${work.dir}" fork="true">
778+
<java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
769779
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
770780
<jvmarg line="${debug-args-line}"/>
771781
<jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
@@ -792,7 +802,7 @@ is divided into following sections:
792802
<attribute default="jvm" name="jvm"/>
793803
<element name="customize" optional="true"/>
794804
<sequential>
795-
<java classname="@{classname}" dir="${work.dir}" fork="true">
805+
<java classname="@{classname}" dir="${work.dir}" failonerror="${java.failonerror}" fork="true">
796806
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
797807
<jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
798808
<redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
@@ -831,7 +841,7 @@ is divided into following sections:
831841
</chainedmapper>
832842
</pathconvert>
833843
<taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
834-
<copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
844+
<copylibs compress="${jar.compress}" excludeFromCopy="${copylibs.excludes}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" manifestencoding="UTF-8" rebase="${copylibs.rebase}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
835845
<fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
836846
<manifest>
837847
<attribute name="Class-Path" value="${jar.classpath}"/>
@@ -843,7 +853,7 @@ is divided into following sections:
843853
</target>
844854
<target name="-init-presetdef-jar">
845855
<presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
846-
<jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
856+
<jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifestencoding="UTF-8">
847857
<j2seproject1:fileset dir="${build.classes.dir}" excludes="${dist.archive.excludes}"/>
848858
</jar>
849859
</presetdef>
@@ -966,23 +976,23 @@ is divided into following sections:
966976
</target>
967977
<target depends="init" if="do.archive+manifest.available" name="-do-jar-copy-manifest">
968978
<tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
969-
<copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
979+
<copy encoding="${manifest.encoding}" file="${manifest.file}" outputencoding="UTF-8" tofile="${tmp.manifest.file}"/>
970980
</target>
971981
<target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+main.class.available" name="-do-jar-set-mainclass">
972-
<manifest file="${tmp.manifest.file}" mode="update">
982+
<manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
973983
<attribute name="Main-Class" value="${main.class}"/>
974984
</manifest>
975985
</target>
976986
<target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+profile.available" name="-do-jar-set-profile">
977-
<manifest file="${tmp.manifest.file}" mode="update">
987+
<manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
978988
<attribute name="Profile" value="${javac.profile}"/>
979989
</manifest>
980990
</target>
981991
<target depends="init,-do-jar-create-manifest,-do-jar-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-set-splashscreen">
982992
<basename file="${application.splash}" property="splashscreen.basename"/>
983993
<mkdir dir="${build.classes.dir}/META-INF"/>
984994
<copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
985-
<manifest file="${tmp.manifest.file}" mode="update">
995+
<manifest encoding="UTF-8" file="${tmp.manifest.file}" mode="update">
986996
<attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
987997
</manifest>
988998
</target>
@@ -1177,7 +1187,7 @@ is divided into following sections:
11771187
<target depends="-profile-check" description="Profile a selected class in the IDE." if="profiler.configured" name="profile-test-with-main">
11781188
<fail unless="run.class">Must select one file in the IDE or set run.class</fail>
11791189
<startprofiler/>
1180-
<antcal target="run-test-with-main"/>
1190+
<antcall target="run-test-with-main"/>
11811191
</target>
11821192
<target depends="-profile-check,-profile-applet-pre72" if="profiler.configured" name="profile-applet" unless="profiler.info.jvmargs.agent">
11831193
<fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
@@ -1199,11 +1209,14 @@ is divided into following sections:
11991209
</not>
12001210
</and>
12011211
</condition>
1202-
<javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
1212+
<condition else="" property="bug5101868workaround" value="*.java">
1213+
<matches pattern="1\.[56](\..*)?" string="${java.version}"/>
1214+
</condition>
1215+
<javadoc additionalparam="-J-Dfile.encoding=${file.encoding} ${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
12031216
<classpath>
12041217
<path path="${javac.classpath}"/>
12051218
</classpath>
1206-
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
1219+
<fileset dir="${src.dir}" excludes="${bug5101868workaround},${excludes}" includes="${includes}">
12071220
<filename name="**/*.java"/>
12081221
</fileset>
12091222
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
@@ -1277,7 +1290,7 @@ is divided into following sections:
12771290
<mkdir dir="${build.test.results.dir}"/>
12781291
</target>
12791292
<target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
1280-
<j2seproject3:test testincludes="**/*Test.java"/>
1293+
<j2seproject3:test includes="${includes}" testincludes="**/*Test.java"/>
12811294
</target>
12821295
<target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
12831296
<fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>

LinkedList/ReverseSinglyLinkedList/nbproject/genfiles.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ [email protected]
44
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
55
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
66
nbproject/build-impl.xml.data.CRC32=0b14902e
7-
nbproject/build-impl.xml.script.CRC32=268bf36f
8-
nbproject/build-impl.xml.stylesheet.CRC32=5a01deb7@1.68.1.46
7+
nbproject/build-impl.xml.script.CRC32=d7462f3a
8+
nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48

0 commit comments

Comments
 (0)