new operator 'groupby'

This commit is contained in:
2026-05-02 14:46:28 +02:00
parent d5ced343c4
commit 3b2ef7927b
12 changed files with 271 additions and 58 deletions
+21 -4
View File
@@ -143,13 +143,12 @@ func (dict *DictType) HasKey(target any) (ok bool) {
return
}
func (dict *DictType) SetItem(key any, value any) (err error) {
func (dict *DictType) SetItem(key any, value any) {
(*dict)[key] = value
return
}
func (dict *DictType) GetItem(key any) (value any, err error) {
value = (*dict)[key]
func (dict *DictType) GetItem(key any) (value any, exists bool) {
value, exists = (*dict)[key]
return
}
@@ -169,6 +168,24 @@ func (dict *DictType) Merge(second *DictType) {
}
}
func (dict *DictType) Equals(dict2 DictType) (answer bool) {
if dict2 != nil && len(*dict) == len(dict2) {
answer = true
for key, value1 := range *dict {
if value2, exists := dict2.GetItem(key); exists {
if !Equal(value1, value2) {
answer = false
break
}
} else {
answer = false
break
}
}
}
return
}
////////////////
type DictFormat interface {