1 pub struct GenericCache<T: Copy> {
9 impl<T:Copy> GenericCache<T> {
10 pub fn new(height: usize, stride: usize, default: T) -> Self {
15 data: Vec::with_capacity((height + 1) * stride),
21 pub fn full_size(&self) -> usize { self.stride * (self.height + 1) }
22 pub fn reset(&mut self) {
23 self.data.truncate(0);
24 let size = self.full_size();
25 self.data.resize(size, self.default);
26 self.xpos = self.stride + 1;
28 pub fn update_row(&mut self) {
29 for i in 0..self.stride {
30 self.data[i] = self.data[self.height * self.stride + i];
32 self.data.truncate(self.stride);
33 let size = self.full_size();
34 self.data.resize(size, self.default);
35 self.xpos = self.stride + 1;