mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-13 05:45:02 +00:00
c6cd0e0c21
1) Added new file map.go, map_test.go 2) Added Map, Hash Method to Item interface 3) Implemented Hash Method for every stack items (Boolean, Array, Int, ...)
36 lines
681 B
Go
36 lines
681 B
Go
package stack
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
// Array represents an Array of stackItems on the stack
|
|
type Array struct {
|
|
*abstractItem
|
|
val []Item
|
|
}
|
|
|
|
// Array overrides the default implementation
|
|
// by the abstractItem, returning an Array struct
|
|
func (a *Array) Array() (*Array, error) {
|
|
return a, nil
|
|
}
|
|
|
|
//Value returns the underlying Array's value
|
|
func (a *Array) Value() []Item {
|
|
return a.val
|
|
}
|
|
|
|
// NewArray returns a new Array.
|
|
func NewArray(val []Item) *Array {
|
|
return &Array{
|
|
&abstractItem{},
|
|
val,
|
|
}
|
|
}
|
|
|
|
// Hash overrides the default abstract hash method.
|
|
func (a *Array) Hash() (string, error) {
|
|
data := fmt.Sprintf("%T %v", a, a.Value())
|
|
return KeyGenerator([]byte(data))
|
|
}
|