You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
551 B

  1. use core::ops::{Index, IndexMut};
  2. use super::entry::*;
  3. use super::ENTRY_COUNT;
  4. pub struct Table {
  5. entries: [Entry; ENTRY_COUNT],
  6. }
  7. impl Table {
  8. pub fn zero(&mut self) {
  9. for entry in self.entries.iter_mut() {
  10. entry.set_unused();
  11. }
  12. }
  13. }
  14. impl Index<usize> for Table {
  15. type Output = Entry;
  16. fn index(&self, index: usize) -> &Entry {
  17. &self.entries[index]
  18. }
  19. }
  20. impl IndexMut<usize> for Table {
  21. fn index_mut(&mut self, index: usize) -> &mut Entry {
  22. &mut self.entries[index]
  23. }
  24. }