1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/**
* Copyright (c) Rich Hickey. All rights reserved.
* The use and distribution terms for this software are covered by the
* Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
* which can be found in the file CPL.TXT at the root of this distribution.
* By using this software in any fashion, you are agreeing to be bound by
* the terms of this license.
* You must not remove this notice, or any other, from this software.
**/
using System;
using System.Collections;
namespace clojure.lang
{
public class PersistentHashtableIdentityMap : PersistentHashtableMap {
public PersistentHashtableIdentityMap(int initialCapacity) : base(initialCapacity) {
}
public PersistentHashtableIdentityMap(Object[] init) : base(init){
}
PersistentHashtableIdentityMap(int count, PersistentArray array) : base(count, array) {
}
PersistentHashtableIdentityMap(int i, PersistentArray newArray, int growAtCount):base(i,newArray,growAtCount){
}
override public IEnumerator GetEnumerator()
{
return new Iter2(array);
}
internal class Iter2 : IEnumerator
{
PersistentArray buckets;
int b;
Object e;
internal Iter2(PersistentArray buckets)
{
this.buckets = buckets;
this.b = -1;
}
private void nextBucket()
{
e = null;
for (b = b + 1; b < buckets.length(); b++)
{
Object a = buckets.get(b);
if (a != null && a != PersistentListIdentityMap.EMPTY)
{
e = a;
break;
}
}
}
#region IEnumerator Members
public object Current
{
get { return e; }
}
public bool MoveNext()
{
if (e == null || (e = ((PersistentListIdentityMap)e).next()) == PersistentListIdentityMap.EMPTY)
nextBucket();
return e != null;
}
public void Reset()
{
throw new Exception("The method or operation is not implemented.");
}
#endregion
}
internal override IPersistentMap create(int capacity) {
PersistentHashtableIdentityMap ret = new PersistentHashtableIdentityMap(capacity);
ret._meta = _meta;
return ret;
}
internal override IPersistentMap create(int count, PersistentArray array) {
PersistentHashtableIdentityMap ret = new PersistentHashtableIdentityMap(count, array);
ret._meta = _meta;
return ret;
}
internal override IPersistentMap create(int i, PersistentArray newArray, int growAtCount){
PersistentHashtableIdentityMap ret = new PersistentHashtableIdentityMap(i, newArray, growAtCount);
ret._meta = _meta;
return ret;
}
internal override IPersistentMap createListMap(Object key, Object val){
return PersistentListIdentityMap.create(key,val);
}
}
}
|