parser: add `is_loose`, `prev_looses` and `next_looses`
[nit.git] / lib / bucketed_game.nit
index 703ff5c..eba5d69 100644 (file)
@@ -48,20 +48,16 @@ class Buckets[G: Game]
        # Bucket type used in this implementation.
        type BUCKET: HashSet[Bucketable[G]]
 
-       private var buckets: Array[BUCKET] is noinit
-
        private var next_bucket: nullable BUCKET = null
        private var current_bucket_key: Int = -1
 
-       init
-       do
-               var n_buckets = 100
-               buckets = new Array[BUCKET].with_capacity(n_buckets)
+       # Number of `buckets`, default at 100
+       #
+       # Must be set prior to using any other methods of this class.
+       var n_buckets = 100
 
-               for b in [0 .. n_buckets [do
-                       buckets[b] = new HashSet[Bucketable[G]]
-               end
-       end
+       private var buckets: Array[BUCKET] =
+               [for b in n_buckets.times do new HashSet[Bucketable[G]]] is lazy
 
        # Add the Bucketable event `e` at `at_tick`.
        fun add_at(e: Bucketable[G], at_tick: Int)
@@ -179,8 +175,6 @@ class Game
        # but cannot be used to add new Events.
        var last_turn: nullable ThinGameTurn[G] = null
 
-       init do end
-
        # Execute and return a new GameTurn.
        #
        # This method calls `do_pre_turn` before executing the GameTurn