summaryrefslogtreecommitdiff
path: root/src/test/java/com/seaofnodes/simple/progs/stringHash.smp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/progs/stringHash.smp')
-rw-r--r--src/test/java/com/seaofnodes/simple/progs/stringHash.smp30
1 files changed, 0 insertions, 30 deletions
diff --git a/src/test/java/com/seaofnodes/simple/progs/stringHash.smp b/src/test/java/com/seaofnodes/simple/progs/stringHash.smp
deleted file mode 100644
index 7344fcdd..00000000
--- a/src/test/java/com/seaofnodes/simple/progs/stringHash.smp
+++ /dev/null
@@ -1,30 +0,0 @@
-// -*- mode: java; -*-
-struct String {
- u8[] cs;
- int _hashCode;
-};
-
-// Compare two Strings
-val equals = { !String !self, !String s ->
- if( self == s ) return true;
- if( self.cs# != s.cs# ) return false;
- for( int i=0; i< self.cs#; i++ )
- if( self.cs[i] != s.cs[i] )
- return false;
- return true;
-};
-
-// Return the String hashCode (cached, and never 0)
-val hashCode = { !String self ->
- self._hashCode
- ? self._hashCode
- : (self._hashCode = _hashCodeString(self));
-};
-
-val _hashCodeString = { !String self ->
- int hash=0;
- for( int i=0; i< self.cs#; i++ )
- hash = hash*31 + self.cs[i];
- if( !hash ) hash = 123456789;
- return hash;
-};