pub struct CompDict<L: Allocator + Copy = Global, S: Allocator + Copy = Global> { /* private fields */ }Expand description
Dictionary for PRS compression.
This dictionary stores the locations of every single possible place that a specified 2-byte sequence
can be found, with the 2 byte combination being the dictionary ‘key’. The values (locations) are
stored inside a shared buffer, where CompDictEntry dictates the file offsets of the locations
which start with this 2 byte combination. The items are stored in ascending order.
When the compressor is looking for longest match at given address, it will read the 2 bytes at the
address and use that as key CompDict::get_item. Then the offsets inside the returned entry
will be used to greatly speed up search.
Implementations§
Source§impl<L: Allocator + Copy, S: Allocator + Copy> CompDict<L, S>
impl<L: Allocator + Copy, S: Allocator + Copy> CompDict<L, S>
Sourcepub unsafe fn init(&mut self, data: &[u8], offset: usize)
pub unsafe fn init(&mut self, data: &[u8], offset: usize)
Initialize the CompDict with the given data and offset.
§Parameters
data: The data to create the dictionary from.offset: The offset to add to the offsets in the dictionary.
§Safety
This function is unsafe as it operates on raw pointers and assumes that
the CompDict has been properly allocated with enough space for data.
Sourcepub unsafe fn get_item(
&mut self,
key: u16,
min_ofs: usize,
max_ofs: usize,
) -> &[u32]
pub unsafe fn get_item( &mut self, key: u16, min_ofs: usize, max_ofs: usize, ) -> &[u32]
Returns a slice of offsets for the given key which are greater than or equal to min_ofs
and less than or equal to max_ofs.
§Parameters
key: The key to search for.min_ofs: The minimum offset returned in the slice.max_ofs: The maximum offset returned in the slice.
§Safety
This function is unsafe as it operates on raw pointers.
Sourcepub fn get_dict_mut(&mut self) -> &mut [CompDictEntry; 65536]
pub fn get_dict_mut(&mut self) -> &mut [CompDictEntry; 65536]
Retrieves the dictionary entries section of this CompDict.