Lines Matching refs:T

22 pub(crate) struct LinkedList<T> {
23 head: *const Node<T>,
24 tail: *const Node<T>,
26 marker: PhantomData<Box<Node<T>>>,
29 impl<T> LinkedList<T> {
53 pub(crate) fn push_back(&mut self, value: T) { in push_back() argument
59 let node = Box::leak(node) as *const Node<T>; in push_back()
64 (*(self.tail as *mut Node<T>)).next = node; in push_back()
73 pub(crate) fn pop_back(&mut self) -> Option<T> { in pop_back() argument
78 let node = Box::from_raw(self.tail as *mut Node<T>); in pop_back()
84 (*(self.tail as *mut Node<T>)).next = null(); in pop_back()
95 pub(crate) fn iter(&self) -> Iter<'_, T> { in iter() argument
106 pub(crate) fn iter_mut(&mut self) -> IterMut<'_, T> { in iter_mut() argument
117 pub(crate) fn cursor_front(&self) -> Cursor<'_, T> { in cursor_front() argument
127 pub(crate) fn cursor_front_mut(&mut self) -> CursorMut<'_, T> { in cursor_front_mut() argument
138 pub(crate) fn cursor_back(&self) -> Cursor<'_, T> { in cursor_back() argument
149 pub(crate) fn cursor_back_mut(&mut self) -> CursorMut<'_, T> { in cursor_back_mut() argument
160 pub(crate) fn back(&self) -> Option<&T> { in back() argument
170 pub(crate) fn back_mut(&mut self) -> Option<&mut T> { in back_mut() argument
174 unsafe { Some(&mut (*(self.tail as *mut Node<T>)).element) } in back_mut()
181 pub(crate) fn back_node(&self) -> Option<&Node<T>> { in back_node() argument
192 pub(crate) fn back_node_mut(&mut self) -> Option<&mut Node<T>> { in back_node_mut() argument
198 let node = &mut *(self.tail as *mut Node<T>); in back_node_mut()
199 node.parent = self as *const LinkedList<T>; in back_node_mut()
206 pub(crate) unsafe fn unlink_node(&mut self, node: *const Node<T>) { in unlink_node() argument
207 let node = &mut (*(node as *mut Node<T>)); in unlink_node()
212 (*(node.prev as *mut Node<T>)).next = node.next; in unlink_node()
218 (*(node.next as *mut Node<T>)).prev = node.prev; in unlink_node()
225 impl<T> Default for LinkedList<T> {
231 impl<T: Debug> Debug for LinkedList<T> {
243 impl<T: PartialEq> PartialEq for LinkedList<T> {
257 impl<T: Clone> Clone for LinkedList<T> {
267 impl<T> Drop for LinkedList<T> {
277 unsafe impl<T: Send> Send for LinkedList<T> {}
278 unsafe impl<T: Sync> Sync for LinkedList<T> {}
281 pub struct Node<T> {
282 next: *const Node<T>,
283 prev: *const Node<T>,
284 parent: *const LinkedList<T>,
285 element: T,
288 impl<T> Node<T> {
290 pub(crate) fn new(element: T) -> Self { in new()
300 pub(crate) fn into_element(self) -> T { in into_element() argument
305 pub(crate) fn get_element_mut(&mut self) -> &mut T { in get_element_mut() argument
311 pub(crate) fn remove_self(&mut self) -> Option<T> { in remove_self() argument
312 let list = unsafe { &mut *(self.parent as *mut LinkedList<T>) }; in remove_self()
315 current: self as *const Node<T>, in remove_self()
323 pub struct Iter<'a, T: 'a> {
324 head: *const Node<T>,
325 tail: *const Node<T>,
327 marker: PhantomData<&'a Node<T>>,
330 impl<'a, T> Iterator for Iter<'a, T> {
331 type Item = &'a T;
334 fn next(&mut self) -> Option<&'a T> { in next() argument
338 let node = unsafe { &*(self.head as *mut Node<T>) }; in next()
352 fn last(mut self) -> Option<&'a T> { in last() argument
358 impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
359 fn next_back(&mut self) -> Option<&'a T> { in next_back() argument
363 let node = unsafe { &*(self.tail as *mut Node<T>) }; in next_back()
372 pub struct IterMut<'a, T: 'a> {
373 head: *const Node<T>,
374 tail: *const Node<T>,
376 marker: PhantomData<&'a mut Node<T>>,
379 impl<'a, T> Iterator for IterMut<'a, T> {
380 type Item = &'a mut T;
383 fn next(&mut self) -> Option<&'a mut T> { in next() argument
387 let node = unsafe { &mut *(self.head as *mut Node<T>) }; in next()
401 fn last(mut self) -> Option<&'a mut T> { in last() argument
407 impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
409 fn next_back(&mut self) -> Option<&'a mut T> { in next_back() argument
413 let node = unsafe { &mut *(self.tail as *mut Node<T>) }; in next_back()
423 pub(crate) struct Cursor<'a, T: 'a> {
425 current: *const Node<T>,
426 list: &'a LinkedList<T>,
429 impl<'a, T> Cursor<'a, T> {
467 pub(crate) fn current(&self) -> Option<&'a T> { in current() argument
477 pub(crate) fn current_node(&self) -> Option<&'a Node<T>> { in current_node() argument
487 pub(crate) fn current_node_ptr(&self) -> *const Node<T> { in current_node_ptr() argument
492 pub(crate) struct CursorMut<'a, T: 'a> {
494 current: *const Node<T>,
495 list: &'a mut LinkedList<T>,
498 impl<'a, T> CursorMut<'a, T> {
536 pub(crate) fn current(&mut self) -> Option<&mut T> { in current() argument
540 unsafe { Some(&mut (*(self.current as *mut Node<T>)).element) } in current()
546 pub(crate) fn current_node(&mut self) -> Option<&'a mut Node<T>> { in current_node() argument
551 let node = &mut *(self.current as *mut Node<T>); in current_node()
552 node.parent = self.list as *mut LinkedList<T>; in current_node()
560 pub(crate) fn remove_current(&mut self) -> Option<T> { in remove_current() argument
569 let unlinked_node = Box::from_raw(unlinked_node as *mut Node<T>); in remove_current()