From: hkhang Date: Wed, 4 Nov 2009 00:47:21 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7e2924c629d5735bf9298579805e7b3dc65eb5b4;p=IRC.git *** empty log message *** --- diff --git a/Robust/src/ClassLibrary/JavaDSM/GlobalString.java b/Robust/src/ClassLibrary/JavaDSM/GlobalString.java index 68c117be..c9441e7e 100644 --- a/Robust/src/ClassLibrary/JavaDSM/GlobalString.java +++ b/Robust/src/ClassLibrary/JavaDSM/GlobalString.java @@ -2,6 +2,7 @@ public class GlobalString { char value[]; int count; int offset; + private int cachedHashcode; public GlobalString() { } @@ -35,6 +36,17 @@ public class GlobalString { } } + public int hashCode() { + if (cachedHashcode!=0) + return cachedHashcode; + int hashcode=0; + for(int i=0; i this.count || endIndex > this.count || beginIndex > endIndex) { -// System.printString("Index error\n"); -// } -// atomic { + } + if (beginIndex > this.count || endIndex > this.count || beginIndex > endIndex) { + System.printString("Index error\n"); + } + atomic { str.value = this.value; str.count = endIndex-beginIndex; str.offset = this.offset + beginIndex; } return str; } + + public boolean equals(String str) { + GlobalString gstr; + + atomic { + gstr = global new GlobalString(str); + } + return equals(gstr); + } + + public boolean equals(Object o) { + if (o.getType()!= getType()) + return false; + + GlobalString gs = (GlobalString)o; + if (gs.count!= count) + return false; + + for(int i = 0; i < count; i++) { + if (gs.value[i+gs.offset] != value[i+offset]) + return false; + } + return true; + } } diff --git a/Robust/src/ClassLibrary/JavaDSM/Work.java b/Robust/src/ClassLibrary/JavaDSM/Work.java index 3a1b59ec..5692cd5b 100644 --- a/Robust/src/ClassLibrary/JavaDSM/Work.java +++ b/Robust/src/ClassLibrary/JavaDSM/Work.java @@ -25,7 +25,6 @@ public class Work extends Thread { boolean isEmpty; while(true) { - atomic { isEmpty = tasks.isTodoListEmpty(); // flag > !keep assigning