summaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/runtime/Associative.cs2
-rw-r--r--src/cli/runtime/IArray.cs4
-rw-r--r--src/cli/runtime/Keyword.cs2
-rw-r--r--src/cli/runtime/PerisistentArrayList.cs10
-rw-r--r--src/cli/runtime/PersistentArray.cs20
-rw-r--r--src/cli/runtime/PersistentArrayMap.cs4
-rw-r--r--src/cli/runtime/PersistentHashtableMap.cs26
-rw-r--r--src/cli/runtime/PersistentListMap.cs8
-rw-r--r--src/cli/runtime/PersistentTreeMap.cs2
-rw-r--r--src/cli/runtime/TObj.cs2
-rw-r--r--src/cli/runtime/Tuple.cs6
-rw-r--r--src/cli/runtime/Var.cs2
12 files changed, 44 insertions, 44 deletions
diff --git a/src/cli/runtime/Associative.cs b/src/cli/runtime/Associative.cs
index 3f14089a..062d9099 100644
--- a/src/cli/runtime/Associative.cs
+++ b/src/cli/runtime/Associative.cs
@@ -16,6 +16,6 @@ namespace clojure.lang
bool contains(object key);
IMapEntry find(object key);
object get(object key);
- IPersistentMap put(object key, object val);
+ IPersistentMap assoc(object key, object val);
}
}
diff --git a/src/cli/runtime/IArray.cs b/src/cli/runtime/IArray.cs
index 8602b1c0..7171740b 100644
--- a/src/cli/runtime/IArray.cs
+++ b/src/cli/runtime/IArray.cs
@@ -16,9 +16,9 @@ namespace clojure.lang
public interface IArray : IPersistentCollection {
int length();
-Object get(int i);
+Object nth(int i);
-IArray set(int i,Object val);
+IArray assocN(int i,Object val);
}
}
diff --git a/src/cli/runtime/Keyword.cs b/src/cli/runtime/Keyword.cs
index 28ba5c73..d23ec19e 100644
--- a/src/cli/runtime/Keyword.cs
+++ b/src/cli/runtime/Keyword.cs
@@ -25,7 +25,7 @@ internal Keyword(String name):base(name) { } public Object invoke() /*throws
if (obj == null)
return null;
return ((IPersistentMap)obj).get(this); } /** * Indexer implements IFn for attr access * This two arg version is the setter * @param tld * @param obj - must be AMap * @param val * @return val */ public Object invoke( Object obj, Object val) /*throws Exception*/ {
- return ((IPersistentMap)obj).put(this, val); }
+ return ((IPersistentMap)obj).assoc(this, val); }
public Object invoke(Object arg1, Object arg2, Object arg3)
{
diff --git a/src/cli/runtime/PerisistentArrayList.cs b/src/cli/runtime/PerisistentArrayList.cs
index 3b9173a1..07e65f5e 100644
--- a/src/cli/runtime/PerisistentArrayList.cs
+++ b/src/cli/runtime/PerisistentArrayList.cs
@@ -33,18 +33,18 @@ PersistentArrayList(int size, Object defaultVal, float loadFactor, int count):ba
this._count = count;
}
-override public Object get(int i) {
+override public Object nth(int i) {
if(i >= _count)
throw new IndexOutOfRangeException();
- return base.get(i);
+ return base.nth(i);
}
-override public IArray set(int i,Object val) {
+override public IArray assocN(int i,Object val) {
if(i >= _count)
throw new IndexOutOfRangeException();
- return (PersistentArrayList) base.set(i, val);
+ return (PersistentArrayList) base.assocN(i, val);
}
override public int length(){
@@ -67,7 +67,7 @@ public PersistentArrayList add(Object val) {
grow();
}
}
- PersistentArrayList ret = (PersistentArrayList) base.set(_count, val);
+ PersistentArrayList ret = (PersistentArrayList) base.assocN(_count, val);
ret._count = _count + 1;
return ret;
}
diff --git a/src/cli/runtime/PersistentArray.cs b/src/cli/runtime/PersistentArray.cs
index 2cabe49e..969833a5 100644
--- a/src/cli/runtime/PersistentArray.cs
+++ b/src/cli/runtime/PersistentArray.cs
@@ -149,7 +149,7 @@ internal class Seq : IndexedSeq{
}
public Object first() {
- return p.get(i);
+ return p.nth(i);
}
public ISeq rest() {
@@ -183,7 +183,7 @@ internal class ValIter : IEnumerator
public object Current
{
- get { return p.get(i); }
+ get { return p.nth(i); }
}
public bool MoveNext()
@@ -250,7 +250,7 @@ public PersistentArray(IArray init) :this(init.length()) {
int load = 0;
for(int i=0;i < init.length();i++)
{
- data.master.array[i] = new Entry(0, init.get(i));
+ data.master.array[i] = new Entry(0, init.nth(i));
++load;
}
@@ -265,7 +265,7 @@ virtual public int length(){
return data.master.array.Length;
}
-virtual public Object get(int i){
+virtual public Object nth(int i){
Entry e = getEntry(i);
if(e != null)
return e.val;
@@ -328,7 +328,7 @@ for (Entry e = (Entry)data.master.array[i]; e != null; e = e.rest())
return null;
}
-virtual public IArray set(int i,Object val) {
+virtual public IArray assocN(int i,Object val) {
//if (data.master.load >= data.master.maxLoad)
// {
// isolate();
@@ -412,7 +412,7 @@ override public bool Equals(Object key){
for(int i = 0; i < length(); i++)
{
- if(!equalKey(get(i),a.get(i)))
+ if(!equalKey(nth(i),a.nth(i)))
return false;
}
@@ -424,7 +424,7 @@ override public int GetHashCode()
int ret = 0;
for (int i = 0; i < length(); i++)
{
- Object o = get(i);
+ Object o = nth(i);
if (o != null)
ret ^= o.GetHashCode();
}
@@ -531,14 +531,14 @@ static public void Main(String[] args){
IArray oldp = p;
for (int i = 0; i < writes; i++)
{
- p = p.set(rand.Next(size), i);
+ p = p.assocN(rand.Next(size), i);
//dummy set to force perverse branching
- oldp = oldp.set(i%size, i);
+ oldp = oldp.assocN(i%size, i);
//p.set(i%size, i);
}
for(int i = 0; i < reads; i++)
{
- tp += (int)p.get(rand.Next(size));
+ tp += (int)p.nth(rand.Next(size));
}
Console.WriteLine("Time: " + (DateTime.Now - start));
Console.WriteLine("Done: " + tv + ", " + tp);
diff --git a/src/cli/runtime/PersistentArrayMap.cs b/src/cli/runtime/PersistentArrayMap.cs
index 15a67d73..ebea6ebd 100644
--- a/src/cli/runtime/PersistentArrayMap.cs
+++ b/src/cli/runtime/PersistentArrayMap.cs
@@ -98,7 +98,7 @@ public IPersistentMap add(Object key, Object val) {
return create(newArray);
}
-public IPersistentMap put(Object key, Object val) {
+public IPersistentMap assoc(Object key, Object val) {
int i = indexOf(key);
Object[] newArray;
if(i >= 0) //already have key, same-sized replacement
@@ -111,7 +111,7 @@ public IPersistentMap put(Object key, Object val) {
else //didn't have key, grow
{
if (array.Length > HASHTABLE_THRESHOLD)
- return createHT(array).put(key, val);
+ return createHT(array).assoc(key, val);
newArray = new Object[array.Length + 2];
if(array.Length > 0)
Array.Copy(array,0,newArray,2,array.Length);
diff --git a/src/cli/runtime/PersistentHashtableMap.cs b/src/cli/runtime/PersistentHashtableMap.cs
index 0cf2206d..7d765aca 100644
--- a/src/cli/runtime/PersistentHashtableMap.cs
+++ b/src/cli/runtime/PersistentHashtableMap.cs
@@ -98,25 +98,25 @@ public IPersistentMap add(Object key, Object val) {
return create(_count + incr, newArray, growAtCount);
}
-public IPersistentMap put(Object key, Object val) {
+public IPersistentMap assoc(Object key, Object val) {
if(_count > growAtCount)
- return grow().put(key, val);
+ return grow().assoc(key, val);
int i = bucketFor(key,array);
int incr = 1;
PersistentArray newArray = doPut(i, key, val, array);
if(newArray == array)
return this;
- if(array.get(i) != null && ((IPersistentMap)newArray.get(i)).count() == ((IPersistentMap)array.get(i)).count()) //key already there, no growth
+ if(array.nth(i) != null && ((IPersistentMap)newArray.nth(i)).count() == ((IPersistentMap)array.nth(i)).count()) //key already there, no growth
incr = 0;
return create(_count + incr, newArray, growAtCount);
}
PersistentArray doPut(int i,Object key,Object val,PersistentArray array){
- IPersistentMap entries = (IPersistentMap) array.get(i);
+ IPersistentMap entries = (IPersistentMap) array.nth(i);
IPersistentMap newEntries;
if (entries != null)
{
- newEntries = entries.put(key, val);
+ newEntries = entries.assoc(key, val);
if(newEntries == entries) //already there with same value, no op
return array;
}
@@ -124,11 +124,11 @@ PersistentArray doPut(int i,Object key,Object val,PersistentArray array){
newEntries = createListMap(key, val);
//newEntries = createArrayMap(new Object[]{key, val});
- return (PersistentArray)array.set(i, newEntries);
+ return (PersistentArray)array.assocN(i, newEntries);
}
PersistentArray doAdd(int i,Object key,Object val,PersistentArray array) {
- IPersistentMap entries = (IPersistentMap) array.get(i);
+ IPersistentMap entries = (IPersistentMap) array.nth(i);
IPersistentMap newEntries;
if (entries != null)
{
@@ -137,16 +137,16 @@ PersistentArray doAdd(int i,Object key,Object val,PersistentArray array) {
else
newEntries = createListMap(key, val);
- return (PersistentArray)array.set(i, newEntries);
+ return (PersistentArray)array.assocN(i, newEntries);
}
public IPersistentMap remove(Object key) {
int i = bucketFor(key,array);
- IPersistentMap entries = (IPersistentMap) array.get(i);
+ IPersistentMap entries = (IPersistentMap) array.nth(i);
if (entries != null)
{
IPersistentMap newEntries = entries.remove(key);
if (newEntries != entries)
- return create(_count - 1, (PersistentArray)array.set(i, newEntries));
+ return create(_count - 1, (PersistentArray)array.assocN(i, newEntries));
}
//not there, no op
return this;
@@ -195,7 +195,7 @@ class Seq : ISeq{
return new Seq(buckets,b,e.rest());
for(b = b+1;b<buckets.length();b++)
{
- IPersistentCollection a = (IPersistentCollection) buckets.get(b);
+ IPersistentCollection a = (IPersistentCollection) buckets.nth(b);
if(a != null && a.seq() != null)
return new Seq(buckets,b,a.seq());
}
@@ -231,7 +231,7 @@ internal class Iter : IEnumerator{
e = null;
for(b = b+1;b<buckets.length();b++)
{
- Object a = buckets.get(b);
+ Object a = buckets.nth(b);
if(a != null && a != PersistentListMap.EMPTY)
{
e = a;
@@ -263,7 +263,7 @@ public void Reset()
}
IPersistentMap entriesFor(Object key){
- return (IPersistentMap) array.get(bucketFor(key,array));
+ return (IPersistentMap) array.nth(bucketFor(key,array));
}
static int bucketFor(Object key, PersistentArray array) {
diff --git a/src/cli/runtime/PersistentListMap.cs b/src/cli/runtime/PersistentListMap.cs
index 8dbdd7ef..d86bdab8 100644
--- a/src/cli/runtime/PersistentListMap.cs
+++ b/src/cli/runtime/PersistentListMap.cs
@@ -68,10 +68,10 @@ public virtual IMapEntry find(Object key){
}
public virtual IPersistentMap add(Object key, Object val){
- return put(key, val);
+ return assoc(key, val);
}
-public virtual IPersistentMap put(Object key, Object val){
+public virtual IPersistentMap assoc(Object key, Object val){
return new Tail(key, val, _meta);
}
@@ -202,7 +202,7 @@ internal class Tail : PersistentListMap {
return new Link(key, val, this,_meta);
}
- override public IPersistentMap put(Object key, Object val)
+ override public IPersistentMap assoc(Object key, Object val)
{
if(equalKey(key,_key)) //replace
{
@@ -289,7 +289,7 @@ internal class Link : PersistentListMap {
return new Link(key,val,this,_meta);
}
- override public IPersistentMap put(Object key, Object val)
+ override public IPersistentMap assoc(Object key, Object val)
{
IMapEntry e = find(key);
if(e != null)
diff --git a/src/cli/runtime/PersistentTreeMap.cs b/src/cli/runtime/PersistentTreeMap.cs
index 768c2724..44f76f45 100644
--- a/src/cli/runtime/PersistentTreeMap.cs
+++ b/src/cli/runtime/PersistentTreeMap.cs
@@ -69,7 +69,7 @@ public IPersistentMap add(Object key,Object val){
return new PersistentTreeMap(comp, t.blacken(), _count + 1, _meta);
}
-public IPersistentMap put(Object key, Object val){
+public IPersistentMap assoc(Object key, Object val){
Box found = new Box(null);
Node t = add(tree, key, val, found);
if(t == null) //null == already contains key
diff --git a/src/cli/runtime/TObj.cs b/src/cli/runtime/TObj.cs
index ba48b9e9..1f98cd1a 100644
--- a/src/cli/runtime/TObj.cs
+++ b/src/cli/runtime/TObj.cs
@@ -23,7 +23,7 @@ public TObj(){
public Object putAttr( Object key, Object val) {
IPersistentMap t = (IPersistentMap) Transaction.get( _attrs);
- t = t.put(key, val);
+ t = t.assoc(key, val);
Transaction.set(_attrs,t);
return val;
}
diff --git a/src/cli/runtime/Tuple.cs b/src/cli/runtime/Tuple.cs
index 7c6c2f02..07560fbf 100644
--- a/src/cli/runtime/Tuple.cs
+++ b/src/cli/runtime/Tuple.cs
@@ -37,12 +37,12 @@ public int length() {
return array.Length;
}
-public Object get(int i){
+public Object nth(int i){
return array[i];
}
-public IArray set(int i, Object val) {
+public IArray assocN(int i, Object val) {
Object[] newArray = (Object[])array.Clone();
newArray[i] = val;
return new Tuple(newArray);
@@ -59,7 +59,7 @@ override public bool Equals(Object key){
for(int i = 0; i < array.Length; i++)
{
- if(!equalKey(array[i],a.get(i)))
+ if(!equalKey(array[i],a.nth(i)))
return false;
}
diff --git a/src/cli/runtime/Var.cs b/src/cli/runtime/Var.cs
index c4b9e7b9..748f60ad 100644
--- a/src/cli/runtime/Var.cs
+++ b/src/cli/runtime/Var.cs
@@ -49,7 +49,7 @@ Binding getThreadBinding() {
if (b == null)
newtb = tb.remove(thread);
else
- newtb = tb.put(thread, b);
+ newtb = tb.assoc(thread, b);
} while (tb != Interlocked.CompareExchange(ref threadBindings, newtb, tb));
} public IFn fn(){ return (IFn)getValue(); } override public Object invoke(){
return fn().invoke();