nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
metamodel: rename 'universal' to 'enum'
[nit.git]
/
lib
/
standard
/
collection
/
hash_collection.nit
diff --git
a/lib/standard/collection/hash_collection.nit
b/lib/standard/collection/hash_collection.nit
index
66a301d
..
13d5a7a
100644
(file)
--- a/
lib/standard/collection/hash_collection.nit
+++ b/
lib/standard/collection/hash_collection.nit
@@
-18,8
+18,8
@@
import hash
# A HashCollection is an array of HashNode[K] indexed by the K hash value
private class HashCollection[K: Object, N: HashNode[K], E]
# A HashCollection is an array of HashNode[K] indexed by the K hash value
private class HashCollection[K: Object, N: HashNode[K], E]
-special Collection[E]
-special ArrayCapable[nullable N]
+ super Collection[E]
+ super ArrayCapable[nullable N]
var _array: nullable NativeArray[nullable N] = null # Used to store items
var _capacity: Int = 0 # Size of _array
redef readable var _length: Int = 0 # Number of items in the map
var _array: nullable NativeArray[nullable N] = null # Used to store items
var _capacity: Int = 0 # Size of _array
redef readable var _length: Int = 0 # Number of items in the map
@@
-184,7
+184,7
@@
special ArrayCapable[nullable N]
end
end
end
end
-private class HashNode[K]
+private class HashNode[K: Object]
var _key: K
type N: HashNode[K]
readable writable var _next_item: nullable N = null
var _key: K
type N: HashNode[K]
readable writable var _next_item: nullable N = null
@@
-197,9
+197,9
@@
private class HashNode[K]
end
end
end
end
-class HashMap[K, V]
-special Map[K, V]
-special HashCollection[K, HashMapNode[K, V], V]
+class HashMap[K: Object, V]
+ super Map[K, V]
+ super HashCollection[K, HashMapNode[K, V], V]
redef fun [](key)
do
redef fun [](key)
do
@@
-266,7
+266,6
@@
special HashCollection[K, HashMapNode[K, V], V]
redef fun []=(key, v)
do
redef fun []=(key, v)
do
- assert key != null
var i = index_at(key)
var c = node_at_idx(i, key)
if c != null then
var i = index_at(key)
var c = node_at_idx(i, key)
if c != null then
@@
-301,8
+300,8
@@
special HashCollection[K, HashMapNode[K, V], V]
end
end
end
end
-class HashMapNode[K, V]
-special HashNode[K]
+class HashMapNode[K: Object, V]
+ super HashNode[K]
redef type N: HashMapNode[K, V]
var _value: V
redef type N: HashMapNode[K, V]
var _value: V
@@
-313,8
+312,8
@@
special HashNode[K]
end
end
end
end
-class HashMapIterator[K, V]
-special MapIterator[K, V]
+class HashMapIterator[K: Object, V]
+ super MapIterator[K, V]
redef fun is_ok do return _node != null
redef fun item
redef fun is_ok do return _node != null
redef fun item
@@
-354,9
+353,9
@@
special MapIterator[K, V]
end
end
end
end
-class HashSet[E]
-special Set[E]
-special HashCollection[E, HashSetNode[E], E]
+class HashSet[E: Object]
+ super Set[E]
+ super HashCollection[E, HashSetNode[E], E]
redef fun is_empty do return _length == 0
redef fun is_empty do return _length == 0
@@
-396,8
+395,8
@@
special HashCollection[E, HashSetNode[E], E]
end
end
end
end
-class HashSetNode[E]
-special HashNode[E]
+class HashSetNode[E: Object]
+ super HashNode[E]
redef type N: HashSetNode[E]
init(e: E)
redef type N: HashSetNode[E]
init(e: E)
@@
-406,8
+405,8
@@
special HashNode[E]
end
end
end
end
-class HashSetIterator[E]
-special Iterator[E]
+class HashSetIterator[E: Object]
+ super Iterator[E]
redef fun is_ok do return _node != null
redef fun item
redef fun is_ok do return _node != null
redef fun item