File tree Expand file tree Collapse file tree 4 files changed +53
-2
lines changed Expand file tree Collapse file tree 4 files changed +53
-2
lines changed Original file line number Diff line number Diff line change 11package delta
22
3+ // ByteSliceDelta 字节数组
4+ func ByteSliceDelta (bytes []byte ) []byte {
5+ result := make ([]byte , 0 )
6+ for index , value := range bytes {
7+ if index == 0 {
8+ result [index ] = value
9+ } else {
10+ result [index ] = bytes [index - 1 ] - value
11+ }
12+ }
13+ return result
14+ }
15+
16+ func ByteSliceFromDelta (bytes []byte ) []byte {
17+ result := make ([]byte , 0 )
18+ for index , value := range bytes {
19+ if index == 0 {
20+ result [index ] = value
21+ } else {
22+ result [index ] = result [index - 1 ] + value
23+ }
24+ }
25+ return result
26+ }
Original file line number Diff line number Diff line change @@ -2,4 +2,8 @@ module github.com/compression-algorithm-research-lab/go-delta
22
33go 1.18
44
5- require github.com/golang-infrastructure/go-gtypes v0.0.1 // indirect
5+ require (
6+ github.com/golang-infrastructure/go-gtypes v0.0.1 // indirect
7+ github.com/golang-infrastructure/go-heap v0.0.2 // indirect
8+ github.com/golang-infrastructure/go-queue v0.0.0-20221128180429-701892f44bcc // indirect
9+ )
Original file line number Diff line number Diff line change 11github.com/golang-infrastructure/go-gtypes v0.0.1 h1:hnM1OYSwLPLGkZ4C6ecAxgmAUaPTjnhnUtRNmJj4p6c =
22github.com/golang-infrastructure/go-gtypes v0.0.1 /go.mod h1:vFMCxFzxdMInvTtgLZRlWI1rS+mui88sMbL5I+zu1hg =
3+ github.com/golang-infrastructure/go-heap v0.0.2 h1:o3u5Wr8W/MO2PjtczBOEwb7HdUgK5zV12aAdp7T28IA =
4+ github.com/golang-infrastructure/go-heap v0.0.2 /go.mod h1:crBY8pM89fprjRYrEGalpJ7xEzhD+XtxiFAuF9JnCuM =
5+ github.com/golang-infrastructure/go-queue v0.0.0-20221128180429-701892f44bcc h1:+i4Y16ygfCIRKnEfwSd7cfQ+KvSMx/ALePIf8wTFRuc =
6+ github.com/golang-infrastructure/go-queue v0.0.0-20221128180429-701892f44bcc /go.mod h1:Ype8CrMpjePHOJq+wRoIN3hx10H/WQsZ5SNvHdiSsBQ =
Original file line number Diff line number Diff line change 11package delta
22
3+ import (
4+ "reflect"
5+ )
6+
37// ZipStructSlice 对Struct序列进行压缩
4- func ZipStructSlice () {
8+ func ZipStructSlice [T any ](slice []T ) {
9+
10+ }
11+
12+ func diff [T any ](a , b T ) * StructDelta {
13+ reflectA := reflect .ValueOf (a )
14+ reflectB := reflect .ValueOf (b )
15+
16+ switch reflectA .Type ().Kind () {
17+ case reflect .String :
18+
19+ }
520}
621
722type StructDelta struct {
23+ Init any
24+ FieldDeltaMap map [string ]* FieldDelta
825}
926
1027type FieldDelta struct {
28+ FieldName string
29+ FieldValue string
1130}
You can’t perform that action at this time.
0 commit comments