@@ -131,14 +131,14 @@ func (d emptyDict) Release() {}
131
131
132
132
type dict struct {
133
133
t semantic.MonoType
134
- data * immutable.SortedMap
134
+ data * immutable.SortedMap [( Value ), ( Value )]
135
135
}
136
136
137
137
func (d dict ) Get (key , def Value ) Value {
138
138
if ! key .IsNull () {
139
139
v , ok := d .data .Get (key )
140
140
if ok {
141
- return v .( Value )
141
+ return v
142
142
}
143
143
}
144
144
return def
@@ -163,11 +163,11 @@ func (d dict) Remove(key Value) Dictionary {
163
163
func (d dict ) Range (f func (key , value Value )) {
164
164
itr := d .data .Iterator ()
165
165
for {
166
- key , value := itr .Next ()
167
- if key == nil {
166
+ key , value , ok := itr .Next ()
167
+ if ! ok {
168
168
return
169
169
}
170
- f (key .( Value ) , value .( Value ) )
170
+ f (key , value )
171
171
}
172
172
}
173
173
@@ -241,7 +241,7 @@ func (d dict) Equal(v Value) bool {
241
241
equal = false
242
242
return
243
243
}
244
- equal = value .Equal (v .( Value ) )
244
+ equal = value .Equal (v )
245
245
})
246
246
return equal
247
247
}
@@ -266,52 +266,52 @@ type (
266
266
timeComparer struct {}
267
267
)
268
268
269
- func (c intComparer ) Compare (a , b interface {} ) int {
270
- if i , j := a .( Value ). Int (), b .( Value ) .Int (); i < j {
269
+ func (c intComparer ) Compare (a , b Value ) int {
270
+ if i , j := a .Int (), b .Int (); i < j {
271
271
return - 1
272
272
} else if i > j {
273
273
return 1
274
274
}
275
275
return 0
276
276
}
277
277
278
- func (c uintComparer ) Compare (a , b interface {} ) int {
279
- if i , j := a .( Value ). UInt (), b .( Value ) .UInt (); i < j {
278
+ func (c uintComparer ) Compare (a , b Value ) int {
279
+ if i , j := a .UInt (), b .UInt (); i < j {
280
280
return - 1
281
281
} else if i > j {
282
282
return 1
283
283
}
284
284
return 0
285
285
}
286
286
287
- func (c floatComparer ) Compare (a , b interface {} ) int {
288
- if i , j := a .( Value ). Float (), b .( Value ) .Float (); i < j {
287
+ func (c floatComparer ) Compare (a , b Value ) int {
288
+ if i , j := a .Float (), b .Float (); i < j {
289
289
return - 1
290
290
} else if i > j {
291
291
return 1
292
292
}
293
293
return 0
294
294
}
295
295
296
- func (c stringComparer ) Compare (a , b interface {} ) int {
297
- if i , j := a .( Value ). Str (), b .( Value ) .Str (); i < j {
296
+ func (c stringComparer ) Compare (a , b Value ) int {
297
+ if i , j := a .Str (), b .Str (); i < j {
298
298
return - 1
299
299
} else if i > j {
300
300
return 1
301
301
}
302
302
return 0
303
303
}
304
304
305
- func (c timeComparer ) Compare (a , b interface {} ) int {
306
- if i , j := a .( Value ). Time (), b .( Value ) .Time (); i < j {
305
+ func (c timeComparer ) Compare (a , b Value ) int {
306
+ if i , j := a .Time (), b .Time (); i < j {
307
307
return - 1
308
308
} else if i > j {
309
309
return 1
310
310
}
311
311
return 0
312
312
}
313
313
314
- func dictComparer (dictType semantic.MonoType ) immutable.Comparer {
314
+ func dictComparer (dictType semantic.MonoType ) immutable.Comparer [( Value )] {
315
315
if dictType .Nature () != semantic .Dictionary {
316
316
panic (UnexpectedKind (dictType .Nature (), semantic .Dictionary ))
317
317
}
@@ -339,7 +339,7 @@ func dictComparer(dictType semantic.MonoType) immutable.Comparer {
339
339
func NewDict (dictType semantic.MonoType ) Dictionary {
340
340
return dict {
341
341
t : dictType ,
342
- data : immutable .NewSortedMap (
342
+ data : immutable.NewSortedMap [( Value ), ( Value )] (
343
343
dictComparer (dictType ),
344
344
),
345
345
}
@@ -350,13 +350,13 @@ func NewDict(dictType semantic.MonoType) Dictionary {
350
350
// that create new Dictionary values.
351
351
type DictionaryBuilder struct {
352
352
t semantic.MonoType
353
- b * immutable.SortedMapBuilder
353
+ b * immutable.SortedMapBuilder [( Value ), ( Value )]
354
354
}
355
355
356
356
// NewDictBuilder will create a new DictionaryBuilder for the given
357
357
// key type.
358
358
func NewDictBuilder (dictType semantic.MonoType ) DictionaryBuilder {
359
- builder := immutable .NewSortedMapBuilder (dictComparer (dictType ))
359
+ builder := immutable.NewSortedMapBuilder [( Value ), ( Value )] (dictComparer (dictType ))
360
360
return DictionaryBuilder {t : dictType , b : builder }
361
361
}
362
362
@@ -374,7 +374,7 @@ func (d *DictionaryBuilder) Get(key Value) (Value, bool) {
374
374
if ! ok {
375
375
return nil , false
376
376
}
377
- return v .( Value ) , true
377
+ return v , true
378
378
}
379
379
380
380
// Insert will insert a new key/value pair into the Dictionary.
0 commit comments