Skip to content

Commit

Permalink
Add tlb.NewHashmapE to construct hashmap from given keys and values
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksej-paschenko committed Dec 13, 2023
1 parent cb5a57e commit 46cd324
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tlb/hashmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ type HashmapE[keyT fixedSize, T any] struct {
m Hashmap[keyT, T]
}

// NewHashmapE returns a new instance of HashmapE.
// Make sure that a key at index "i" corresponds to a value at the same index.
func NewHashmapE[keyT fixedSize, T any](keys []keyT, values []T) HashmapE[keyT, T] {
return HashmapE[keyT, T]{
m: Hashmap[keyT, T]{
keys: keys,
values: values,
},
}
}

func (h HashmapE[keyT, T]) MarshalTLB(c *boc.Cell, encoder *Encoder) error {
var temp Maybe[Ref[Hashmap[keyT, T]]]
temp.Exists = len(h.m.keys) > 0
Expand Down

0 comments on commit 46cd324

Please sign in to comment.