64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Loop over the MTF table
for j := byte(1); j != 0; j++ {
if c.table[j] == value {
// Output the value
buffer[index] = j
// Shift the table
copy(c.table[1:j+1], c.table[0:j])
// Restore the value in front and break
c.table[0] = value
break
}
}
}
|
|
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
// Loop over the MTF table
for j := byte(1); j != 0; j++ {
if c.table[j] == value {
// Output the value
buffer[index] = j
// Shift the table
copy(c.table[1:], c.table[:j])
// Restore the value in front and break
c.table[0] = value
break
}
}
}
|
111
112
113
114
115
116
117
118
119
120
121
122
123
|
continue
}
// Output the value
output[i] = c.table[position]
// Shift the table and restore the value in front
copy(c.table[1:position+1], c.table[0:position])
c.table[0] = output[i]
}
return count, err
}
|
|
|
111
112
113
114
115
116
117
118
119
120
121
122
123
|
continue
}
// Output the value
output[i] = c.table[position]
// Shift the table and restore the value in front
copy(c.table[1:], c.table[:position])
c.table[0] = output[i]
}
return count, err
}
|