summaryrefslogtreecommitdiff
path: root/src/org/clojure
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2006-06-05 15:04:51 +0000
committerRich Hickey <richhickey@gmail.com>2006-06-05 15:04:51 +0000
commit0eb8b48657c82fa2d301fef08180e51cddd3d3ff (patch)
treead76ca6fb81bb1bfd5778f8b6727b640908aded3 /src/org/clojure
parent6d980568070ae1d44e52613eb58ca1a64ff2649b (diff)
storing loadFactor
Diffstat (limited to 'src/org/clojure')
-rw-r--r--src/org/clojure/runtime/PersistentArray.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/org/clojure/runtime/PersistentArray.java b/src/org/clojure/runtime/PersistentArray.java
index 58321629..30fd2636 100644
--- a/src/org/clojure/runtime/PersistentArray.java
+++ b/src/org/clojure/runtime/PersistentArray.java
@@ -59,14 +59,16 @@ static class Master{
final AtomicInteger rev;
final AtomicInteger load;
final int maxLoad;
+ final float loadFactor;
- Master(int size,Object defaultVal, double loadFactor){
+ Master(int size,Object defaultVal, float loadFactor){
this.array = new AtomicReferenceArray(size);
this.defaultVal = defaultVal;
this.rev = new AtomicInteger(0);
this.load = new AtomicInteger(0);
this.maxLoad = (int) (size * loadFactor);
- }
+ this.loadFactor = loadFactor;
+ }
}
static class Entry{
@@ -113,10 +115,10 @@ public PersistentArray(int size){
}
public PersistentArray(int size, Object defaultVal){
- this(size,defaultVal,2.1);
+ this(size,defaultVal,2.1f);
}
-public PersistentArray(int size, Object defaultVal, double loadFactor){
+public PersistentArray(int size, Object defaultVal, float loadFactor){
this.master = new Master(size, defaultVal,loadFactor);
this.rev = 0;
this.baseline = 0;
@@ -148,7 +150,7 @@ public boolean has(int i){
}
public PersistentArray resize(int newLength) {
- PersistentArray ret = new PersistentArray(newLength, master.defaultVal, ((double)master.maxLoad)/length());
+ PersistentArray ret = new PersistentArray(newLength, master.defaultVal, master.loadFactor);
int load = 0;
for(int i=0;i< Math.min(length(),newLength);i++)
{