(snapshot []byte)
| 97 | } |
| 98 | |
| 99 | func (s *State) Decode(snapshot []byte) { |
| 100 | dec := arith.NewDecoder(snapshot) |
| 101 | |
| 102 | s.Current().Assign(s.Baseline()) |
| 103 | historic := s.Historic().Cubes |
| 104 | _ = historic |
| 105 | baseline := s.Baseline().Cubes |
| 106 | current := s.Current().Cubes |
| 107 | |
| 108 | mzeros := mZeros() |
| 109 | |
| 110 | items := []int{} |
| 111 | for i := range current { |
| 112 | if mzeros.Decode(dec) == 1 { |
| 113 | items = append(items, i) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | for _, i := range items { |
| 118 | cube := ¤t[i] |
| 119 | cube.Interacting = mzeros.Decode(dec) == 0 |
| 120 | } |
| 121 | |
| 122 | props := IndexProps(items, len(baseline)) |
| 123 | SortByZ(props, Props(baseline)) |
| 124 | setProp := SetProps(current) |
| 125 | |
| 126 | nbits := uint(0) |
| 127 | for mzeros.Decode(dec) == 0 { |
| 128 | nbits += 1 |
| 129 | } |
| 130 | |
| 131 | if nbits == 0 { |
| 132 | for _, i := range props { |
| 133 | setProp(i, 0) |
| 134 | } |
| 135 | return |
| 136 | } |
| 137 | |
| 138 | mvalues := mValues(nbits) |
| 139 | for _, i := range props { |
| 140 | z := mvalues.Decode(dec) |
| 141 | v := bit.ZDecode(uint64(z)) |
| 142 | setProp(i, int(v)) |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | func IndexProps(index []int, N int) []int { |
| 147 | r := make([]int, 0, len(index)*7) |
no test coverage detected