Struct SplitOrderedList

Source
pub struct SplitOrderedList<V> {
    list: List<usize, MaybeUninit<V>>,
    buckets: GrowableArray<Node<usize, MaybeUninit<V>>>,
    size: AtomicUsize,
    count: AtomicUsize,
}
Expand description

Lock-free map from usize in range [0, 2^63-1] to V.

NOTE: We don’t care about hashing in this homework for simplicity.

Fields§

§list: List<usize, MaybeUninit<V>>

Lock-free list sorted by recursive-split order.

Use MaybeUninit::uninit() when creating sentinel nodes.

§buckets: GrowableArray<Node<usize, MaybeUninit<V>>>

Array of pointers to the buckets.

§size: AtomicUsize

Number of buckets.

§count: AtomicUsize

Number of items.

Implementations§

Source§

impl<V> SplitOrderedList<V>

Source

const LOAD_FACTOR: usize = 2usize

size is doubled when count > size * LOAD_FACTOR.

Source

pub fn new() -> Self

Creates a new split ordered list.

Source

fn lookup_bucket<'s>( &'s self, index: usize, guard: &'s Guard, ) -> Cursor<'s, usize, MaybeUninit<V>>

Creates a cursor and moves it to the bucket for the given index. If the bucket doesn’t exist, recursively initializes the buckets.

Source

fn find<'s>( &'s self, key: &usize, guard: &'s Guard, ) -> (usize, bool, Cursor<'s, usize, MaybeUninit<V>>)

Moves the bucket cursor returned from lookup_bucket to the position of the given key. Returns (size, found, cursor)

Source

fn assert_valid_key(key: usize)

Trait Implementations§

Source§

impl<V> ConcurrentMap<usize, V> for SplitOrderedList<V>

Source§

fn lookup<'a>(&'a self, key: &usize, guard: &'a Guard) -> Option<&'a V>

Lookups the given key to get the reference to its value.
Source§

fn insert(&self, key: usize, value: V, guard: &Guard) -> Result<(), V>

Inserts a key-value pair.
Source§

fn delete<'a>(&'a self, key: &usize, guard: &'a Guard) -> Result<&'a V, ()>

Deletes the given key and returns a reference to its value. Read more
Source§

impl<V: Debug> Debug for SplitOrderedList<V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V> Default for SplitOrderedList<V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<V> !Freeze for SplitOrderedList<V>

§

impl<V> RefUnwindSafe for SplitOrderedList<V>
where V: RefUnwindSafe,

§

impl<V> Send for SplitOrderedList<V>
where V: Send + Sync,

§

impl<V> Sync for SplitOrderedList<V>
where V: Sync + Send,

§

impl<V> Unpin for SplitOrderedList<V>

§

impl<V> UnwindSafe for SplitOrderedList<V>
where V: RefUnwindSafe,

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V