github.com/ledgerwatch/erigon-lib@v1.0.0/state/domain_shared.go (about)

     1  package state
     2  
     3  // KvList sort.Interface to sort write list by keys
     4  type KvList struct {
     5  	Keys []string
     6  	Vals [][]byte
     7  }
     8  
     9  func (l *KvList) Push(key string, val []byte) {
    10  	l.Keys = append(l.Keys, key)
    11  	l.Vals = append(l.Vals, val)
    12  }
    13  
    14  func (l *KvList) Len() int {
    15  	return len(l.Keys)
    16  }
    17  
    18  func (l *KvList) Less(i, j int) bool {
    19  	return l.Keys[i] < l.Keys[j]
    20  }
    21  
    22  func (l *KvList) Swap(i, j int) {
    23  	l.Keys[i], l.Keys[j] = l.Keys[j], l.Keys[i]
    24  	l.Vals[i], l.Vals[j] = l.Vals[j], l.Vals[i]
    25  }