Skip to main content

TypedMap

Struct TypedMap 

Source
#[repr(C)]
pub struct TypedMap<K, V> { pub header: HeapHeader, pub buckets: *mut Bucket<K, V>, pub bucket_count: u32, pub len: u32, pub tombstone_count: u32, pub _pad: u32, }
Expand description

Typed open-addressing hash map with linear probing.

Fields§

§header: HeapHeader§buckets: *mut Bucket<K, V>

Pointer to bucket array.

§bucket_count: u32

Number of buckets (always a power of 2).

§len: u32

Number of live entries.

§tombstone_count: u32

Number of tombstones.

§_pad: u32

Implementations§

Source§

impl<K: Copy, V: Copy> TypedMap<K, V>

Source

pub fn new() -> *mut Self

Allocate a new empty TypedMap.

Source

pub unsafe fn len(this: *const Self) -> u32

Number of entries.

§Safety

this must point to a valid TypedMap.

Source

pub unsafe fn is_empty(this: *const Self) -> bool

Whether the map is empty.

§Safety

this must point to a valid TypedMap.

Source

pub unsafe fn drop_map(ptr: *mut Self)

Deallocate the map and its bucket array.

§Safety

ptr must point to a TypedMap allocated by this module.

Source§

impl<V: Copy> TypedMap<*const u8, V>

Source

pub unsafe fn insert( this: *mut Self, key: *const StringObj, value: V, ) -> Option<V>

Insert a key-value pair. If the key already exists, updates the value and returns the old value.

The map retains the key pointer (caller must ensure it stays alive via refcounting). If the key already exists, the existing key pointer is kept.

§Safety

this must point to a valid TypedMap. key must point to a valid StringObj.

Source

pub unsafe fn get(this: *const Self, key: *const StringObj) -> Option<V>

Look up a value by string key.

§Safety

this must point to a valid TypedMap. key must point to a valid StringObj.

Source

pub unsafe fn contains_key(this: *const Self, key: *const StringObj) -> bool

Check if the map contains a key.

§Safety

this must point to a valid TypedMap. key must point to a valid StringObj.

Source

pub unsafe fn remove(this: *mut Self, key: *const StringObj) -> Option<V>

Remove a key from the map, returning the value if it was present.

§Safety

this must point to a valid TypedMap. key must point to a valid StringObj.

Source§

impl<V: Copy> TypedMap<i64, V>

Source

pub unsafe fn insert_i64(this: *mut Self, key: i64, value: V) -> Option<V>

Insert a key-value pair. If the key already exists, updates the value and returns the old value.

§Safety

this must point to a valid TypedMap<i64, V>.

Source

pub unsafe fn get_i64(this: *const Self, key: i64) -> Option<V>

Look up a value by i64 key.

§Safety

this must point to a valid TypedMap<i64, V>.

Source

pub unsafe fn contains_key_i64(this: *const Self, key: i64) -> bool

Check if the map contains an i64 key.

§Safety

this must point to a valid TypedMap<i64, V>.

Source

pub unsafe fn remove_i64(this: *mut Self, key: i64) -> Option<V>

Remove an i64 key from the map, returning the value if it was present.

§Safety

this must point to a valid TypedMap<i64, V>.

Auto Trait Implementations§

§

impl<K, V> !Freeze for TypedMap<K, V>

§

impl<K, V> RefUnwindSafe for TypedMap<K, V>

§

impl<K, V> !Send for TypedMap<K, V>

§

impl<K, V> !Sync for TypedMap<K, V>

§

impl<K, V> Unpin for TypedMap<K, V>

§

impl<K, V> UnsafeUnpin for TypedMap<K, V>

§

impl<K, V> UnwindSafe for TypedMap<K, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.