Simple complete conflict avoidance.
This commit is contained in:
parent
993fb0730c
commit
2e9c699600
3 changed files with 83 additions and 18 deletions
|
|
@ -27,15 +27,35 @@ where
|
|||
}
|
||||
|
||||
pub fn get(&self, x: usize, y: usize) -> &T {
|
||||
assert!(x < self.width);
|
||||
assert!(y < self.height);
|
||||
assert!(
|
||||
x < self.width,
|
||||
"assertion failed: x < self.width; x: {}, self.width: {}",
|
||||
x,
|
||||
self.width
|
||||
);
|
||||
assert!(
|
||||
y < self.height,
|
||||
"assertion failed: y < self.height; y: {}, self.height: {}",
|
||||
y,
|
||||
self.height
|
||||
);
|
||||
let i = self.index(x, y);
|
||||
self.data.get(i).unwrap()
|
||||
}
|
||||
|
||||
pub fn get_mut(&mut self, x: usize, y: usize) -> &mut T {
|
||||
assert!(x < self.width);
|
||||
assert!(y < self.height);
|
||||
assert!(
|
||||
x < self.width,
|
||||
"assertion failed: x < self.width; x: {}, self.width: {}",
|
||||
x,
|
||||
self.width
|
||||
);
|
||||
assert!(
|
||||
y < self.height,
|
||||
"assertion failed: y < self.height; y: {}, self.height: {}",
|
||||
y,
|
||||
self.height
|
||||
);
|
||||
let i = self.index(x, y);
|
||||
self.data.get_mut(i).unwrap()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue