Lines Matching defs:element

6876     // Other elements are dropped when `drop` of one element panicked.
7553 assert_eq!(Rc::strong_count(&drop_count[1]), 2, "one element was collected");
7868 // Verify that if the filter could panic again on another element
7920 // Verify that if the filter could panic again on another element
8191 /// Pull an element from the iterator, then drop it.
8223 v.swap_remove(1); // swap_remove the last element
8323 // If the element size is 1, we jump from 0 to 8, then double.
8349 // If the element size is 2..=1024, we jump from 0 to 4, then double.
8392 // If the element size is > 1024, we jump from 0 to 1, then double.
9724 // number this element is, i.e., the second elements
9735 // Only sort on the first element, so an unstable sort
13695 // Destructors must be called exactly once per element.
13889 /// - Create a [`Vec`] from a given element and size:
14534 // - 8 if the element size is 1, because any heap allocators is likely
17340 /// This is an *O*(*n*) operation, as it requires copying every element in the
17505 /// This is an *O*(*n*) operation as it requires copying every element in the
17552 /// This is an *O*(*n*) operation as it requires copying every element in the
17712 /// Note: The element range is removed even if the iterator is not
20831 // Pointer to first element
21342 /// Takes each element in the `Iterator` and collects it into an `Rc<[T]>`.
21988 //! while the mutable slice type is `&mut [T]`, where `T` represents the element
22011 //! * [`Eq`], [`Ord`] - for slices whose element type are [`Eq`] or [`Ord`].
22012 //! * [`Hash`] - for slices whose element type is [`Hash`].
22036 //! the element type of the slice is `i32`, the element type of the iterator is
22294 /// significantly faster, as it does not recompute element keys.
22330 /// During sorting, the key function is called only once per element.
22821 // 2. Iterate until the right place for the first element is found. Then shift the
22825 // 3. Copy the first element into a temporary variable. Iterate until the right place
22826 // for it is found. As we go along, copy every traversed element into the slot
24483 // Pointer to first element
25683 /// Takes each element in the `Iterator` and collects it into an `Arc<[T]>`.
26993 element: T,
27029 // We do *not* exclusively own the entire list here, references to node's `element`
27031 // called must be aware that there can be aliasing pointers to `element`.
27065 fn new(element: T) -> Self {
27066 Node { next: None, prev: None, element }
27070 self.element
27080 // to maintain validity of aliasing pointers into `element`.
27088 // Not creating new mutable (unique!) references overlapping `element`.
27101 // to maintain validity of aliasing pointers into `element`.
27108 // Not creating new mutable (unique!) references overlapping `element`.
27121 // to maintain validity of aliasing pointers into `element`.
27129 // Not creating new mutable (unique!) references overlapping `element`.
27142 // to maintain validity of aliasing pointers into `element`.
27149 // Not creating new mutable (unique!) references overlapping `element`.
27162 /// This method takes care not to create mutable references to `element`, to
27168 // Not creating new mutable (unique!) references overlapping `element`.
27197 // to maintain validity of aliasing pointers into `element`.
27448 /// for element in list.iter_mut() {
27449 /// *element += 10;
27464 /// Provides a cursor at the front element.
27466 /// The cursor is pointing to the "ghost" non-element if the list is empty.
27473 /// Provides a cursor with editing operations at the front element.
27475 /// The cursor is pointing to the "ghost" non-element if the list is empty.
27482 /// Provides a cursor at the back element.
27484 /// The cursor is pointing to the "ghost" non-element if the list is empty.
27491 /// Provides a cursor with editing operations at the back element.
27493 /// The cursor is pointing to the "ghost" non-element if the list is empty.
27574 /// Returns `true` if the `LinkedList` contains an element equal to the
27599 /// Provides a reference to the front element, or `None` if the list is
27616 unsafe { self.head.as_ref().map(|node| &node.as_ref().element) }
27619 /// Provides a mutable reference to the front element, or `None` if the list
27642 unsafe { self.head.as_mut().map(|node| &mut node.as_mut().element) }
27645 /// Provides a reference to the back element, or `None` if the list is
27662 unsafe { self.tail.as_ref().map(|node| &node.as_ref().element) }
27665 /// Provides a mutable reference to the back element, or `None` if the list
27688 unsafe { self.tail.as_mut().map(|node| &mut node.as_mut().element) }
27691 /// Adds an element first in the list.
27713 /// Removes the first element and returns it, or `None` if the list is
27737 /// Appends an element to the back of a list.
27756 /// Removes the last element from a list and returns it, or `None` if
27834 /// Removes the element at the given index and returns it.
27880 /// Creates an iterator which uses a closure to determine if an element should be removed.
27882 /// If the closure returns true, then the element is removed and yielded.
27883 /// If the closure returns false, the element will remain in the list and will not be yielded
27886 /// Note that `drain_filter` lets you mutate every element in the filter closure, regardless of
27954 &node.element
27982 &node.element
28008 &mut node.element
28036 &mut node.element
28053 /// To accommodate this, there is a "ghost" non-element that yields `None` between the head and
28056 /// When created, cursors start at the front of the list, or the "ghost" non-element if the list is empty.
28087 /// To accommodate this, there is a "ghost" non-element that yields `None` between the head and
28107 /// "ghost" non-element.
28114 /// Moves the cursor to the next element of the `LinkedList`.
28116 /// If the cursor is pointing to the "ghost" non-element then this will move it to
28117 /// the first element of the `LinkedList`. If it is pointing to the last
28118 /// element of the `LinkedList` then this will move it to the "ghost" non-element.
28122 // We had no current element; the cursor was sitting at the start position
28123 // Next element should be the head of the list
28128 // We had a previous element, so let's go to its next
28136 /// Moves the cursor to the previous element of the `LinkedList`.
28138 /// If the cursor is pointing to the "ghost" non-element then this will move it to
28139 /// the last element of the `LinkedList`. If it is pointing to the first
28140 /// element of the `LinkedList` then this will move it to the "ghost" non-element.
28149 // Have a prev. Yield it and go to the previous element.
28157 /// Returns a reference to the element that the cursor is currently
28161 /// "ghost" non-element.
28164 unsafe { self.current.map(|current| &(*current.as_ptr()).element) }
28167 /// Returns a reference to the next element.
28169 /// If the cursor is pointing to the "ghost" non-element then this returns
28170 /// the first element of the `LinkedList`. If it is pointing to the last
28171 /// element of the `LinkedList` then this returns `None`.
28179 next.map(|next| &(*next.as_ptr()).element)
28183 /// Returns a reference to the previous element.
28185 /// If the cursor is pointing to the "ghost" non-element then this returns
28186 /// the last element of the `LinkedList`. If it is pointing to the first
28187 /// element of the `LinkedList` then this returns `None`.
28195 prev.map(|prev| &(*prev.as_ptr()).element)
28204 /// "ghost" non-element.
28211 /// Moves the cursor to the next element of the `LinkedList`.
28213 /// If the cursor is pointing to the "ghost" non-element then this will move it to
28214 /// the first element of the `LinkedList`. If it is pointing to the last
28215 /// element of the `LinkedList` then this will move it to the "ghost" non-element.
28219 // We had no current element; the cursor was sitting at the start position
28220 // Next element should be the head of the list
28225 // We had a previous element, so let's go to its next
28233 /// Moves the cursor to the previous element of the `LinkedList`.
28235 /// If the cursor is pointing to the "ghost" non-element then this will move it to
28236 /// the last element of the `LinkedList`. If it is pointing to the first
28237 /// element of the `LinkedList` then this will move it to the "ghost" non-element.
28246 // Have a prev. Yield it and go to the previous element.
28254 /// Returns a reference to the element that the cursor is currently
28258 /// "ghost" non-element.
28261 unsafe { self.current.map(|current| &mut (*current.as_ptr()).element) }
28264 /// Returns a reference to the next element.
28266 /// If the cursor is pointing to the "ghost" non-element then this returns
28267 /// the first element of the `LinkedList`. If it is pointing to the last
28268 /// element of the `LinkedList` then this returns `None`.
28276 next.map(|next| &mut (*next.as_ptr()).element)
28280 /// Returns a reference to the previous element.
28282 /// If the cursor is pointing to the "ghost" non-element then this returns
28283 /// the last element of the `LinkedList`. If it is pointing to the first
28284 /// element of the `LinkedList` then this returns `None`.
28292 prev.map(|prev| &mut (*prev.as_ptr()).element)
28296 /// Returns a read-only cursor pointing to the current element.
28310 /// Inserts a new element into the `LinkedList` after the current one.
28312 /// If the cursor is pointing at the "ghost" non-element then the new element is
28324 // The "ghost" non-element's index has changed.
28330 /// Inserts a new element into the `LinkedList` before the current one.
28332 /// If the cursor is pointing at the "ghost" non-element then the new element is
28347 /// Removes the current element from the `LinkedList`.
28349 /// The element that was removed is returned, and the cursor is
28350 /// moved to point to the next element in the `LinkedList`.
28352 /// If the cursor is currently pointing to the "ghost" non-element then no element
28361 Some(unlinked_node.element)
28365 /// Removes the current element from the `LinkedList` without deallocating the list node.
28368 /// The cursor is moved to point to the next element in the current `LinkedList`.
28370 /// If the cursor is currently pointing to the "ghost" non-element then no element
28392 /// If the cursor is pointing at the "ghost" non-element then the new elements are
28407 // The "ghost" non-element's index has changed.
28415 /// If the cursor is pointing at the "ghost" non-element then the new elements are
28433 /// Splits the list into two after the current element. This will return a
28437 /// If the cursor is pointing at the "ghost" non-element then the entire contents
28443 // The "ghost" non-element's index has changed to 0.
28449 /// Splits the list into two before the current element. This will return a
28453 /// If the cursor is pointing at the "ghost" non-element then the entire contents
28489 if (self.pred)(&mut node.as_mut().element) {
28490 // `unlink_node` is okay with aliasing `element` references.
28492 return Some(Box::from_raw(node.as_ptr()).element);
29818 // - If the root node is internal, it must contain at least 1 element.
29829 /// comparisons necessary to find an element (log<sub>2</sub>n). However, in practice the way this
29830 /// is done is *very* inefficient for modern computer architectures. In particular, every element
29842 /// that initially only checks every i<sup>th</sup> element for some choice of i.
29847 /// and possibly other factors. Using linear search, searching for a random element is expected
30423 /// Removes and returns the first element in the map.
30424 /// The key of this element is the minimum key that was in the map.
30506 /// Removes and returns the last element in the map.
30507 /// The key of this element is the maximum key that was in the map.
30973 /// ascending key order and uses a closure to determine if an element should
30974 /// be removed. If the closure returns `true`, the element is removed from
30976 /// element remains in the map and will not be yielded.
30978 /// The iterator also lets you mutate the value of each element in the
30983 /// change its value and, by returning `true`, have the element removed and
30988 /// dropping an element, or if the `DrainFilter` value is leaked.
31032 /// The iterator element type is `K`.
31055 /// The iterator element type is `V`.
31422 /// Contains a leaf edge preceding the next element to be returned, or the last leaf edge.
31467 /// Allow Debug implementations to predict the next element.
35583 // It's not the minimum size: removing an element from such a tree does not always reduce height.
35588 // It's not the minimum size: removing an element from such a tree does not always reduce height.
35713 // - 1 element in internal root node with 2 children
35725 // - 1 element in internal root node with 2 children
37810 // the element we were asked to remove. Prefer the left adjacent KV,
38362 /// Borrows exclusive access to an element of the key storage area.
38376 /// Borrows exclusive access to an element or slice of the node's value storage area.
38392 /// Borrows exclusive access to an element or slice of the node's storage area for edge contents.
38411 // We only create a reference to the one element we are interested in,
39564 /// Inserts a value into a slice of initialized elements followed by one uninitialized element.
39581 /// trailing uninitialized element.
39863 /// provisions an extra element to allow merging its children in turn
39883 /// provisions an extra element to allow merging its children in turn
40431 /// now-contiguous element sequence.
40442 // to the first element that could be read, Head always points
40537 /// Moves an element out of the buffer
40543 /// Writes an element into the buffer, moving it.
40557 /// Returns the index in the underlying buffer for a given logical element
40564 /// Returns the index in the underlying buffer for a given logical element
40571 /// Returns the index in the underlying buffer for a given logical element
40840 /// Provides a reference to the element at the given index.
40865 /// Provides a mutable reference to the element at the given index.
41151 // At all other times, element positions are unaffected.
41509 /// Note 1: The element range is removed even if the iterator is not
41608 /// Returns `true` if the `VecDeque` contains an element equal to the
41633 /// Provides a reference to the front element, or `None` if the `VecDeque` is
41653 /// Provides a mutable reference to the front element, or `None` if the
41677 /// Provides a reference to the back element, or `None` if the `VecDeque` is
41697 /// Provides a mutable reference to the back element, or `None` if the
41721 /// Removes the first element and returns it, or `None` if the `VecDeque` is
41748 /// Removes the last element from the `VecDeque` and returns it, or `None` if
41773 /// Prepends an element to the `VecDeque`.
41798 /// Appends an element to the back of the `VecDeque`.
41828 /// Removes an element from anywhere in the `VecDeque` and returns it,
41829 /// replacing it with the first element.
41863 /// Removes an element from anywhere in the `VecDeque` and returns it, replacing it with the
41864 /// last element.
41898 /// Inserts an element at `index` within the `VecDeque`, shifting all elements with indices
41945 // o - Valid element
41946 // I - Insertion element
41947 // A - The element that should be after the insertion point
41948 // M - Indicates element was moved
42045 // copy last element into empty spot at bottom of buffer
42048 // move elements from idx to end forward not including ^ element
42069 // copy last element into empty spot at bottom of buffer
42089 // copy last element into empty spot at bottom of buffer
42092 // move elements from idx-1 to end forward not including ^ element
42122 /// Removes and returns the element at `index` from the `VecDeque`.
42162 // o - Valid element
42164 // R - Indicates element that is being removed
42165 // M - Indicates element was moved
42262 // copy first element into empty spot
42286 // copy last element into empty spot
42397 /// This method operates in place, visiting each element exactly once in the
42755 /// Binary searches this sorted `VecDeque` for a given element.
42758 /// index of the matching element. If there are multiple matches, then any
42761 /// element could be inserted while maintaining sorted order.
42818 /// index of the matching element. If there are multiple matches, then any
42821 /// element could be inserted while maintaining sorted order.
42870 /// index of the matching element. If there are multiple matches, then any
42873 /// element could be inserted while maintaining sorted order.
42914 /// (the index of the first element of the second partition).
42987 /// Returns the index in the underlying buffer for a given logical element index.
43150 while let Some(element) = iter.next() {
43159 self.buffer_write(head, element);
44270 //! Insertion and popping the largest element have *O*(log(*n*)) time complexity.
44271 //! Checking the largest element is *O*(1). Converting a vector to a binary heap
44790 // order to move an element out of the vector (leaving behind a
44791 // hole), shift along the others and move the removed element back into the
44813 if hole.element() <= unsafe { hole.get(parent) } {
44824 /// Take an element at `pos` and move it down the heap,
44849 if hole.element() >= unsafe { hole.get(child) } {
44860 if child == end - 1 && hole.element() < unsafe { hole.get(child) } {
44877 /// Take an element at `pos` and move it all the way down the heap,
44880 /// Note: This is faster when the element is known to be large / should
45408 /// Returns a reference to the element removed.
45410 fn element(&self) -> &T {
45414 /// Returns a reference to the element at `index`.
46017 // is guaranteed to pointer to an element of the `Vec<T>` and
46176 iterator.for_each(move |element| {
46177 ptr::write(ptr, element);
46461 Some(element) => {
46465 ptr::write(vector.as_mut_ptr(), element);
46764 /// collected. `end` is the last writable element of the allocation and used for bounds checks.
46795 // Safety: InplaceIterable contract guarantees that for every element we read
46971 /// It can also initialize each element of a `Vec<T>` with a given value.
47798 /// Truncating a five element vector to two elements:
48049 /// Removes an element from the vector and returns it.
48051 /// The removed element is replaced by the last element of the vector.
48084 // We replace self[index] with the last element. Note that if the
48085 // bounds check above succeeds there must be a last element (which
48094 /// Inserts an element at position `index` within the vector, shifting all
48111 pub fn insert(&mut self, index: usize, element: T) {
48123 // space for the new element
48134 // `index`th element into two consecutive places.)
48137 // element.
48138 ptr::write(p, element);
48144 /// Removes and returns the element at position `index` within the vector,
48191 /// This method operates in place, visiting each element exactly once in the
48227 // Hole: Moved or dropped element slot.
48230 // This drop guard will be invoked when predicate or `drop` of element panicked.
48262 // SAFETY: Unchecked element must be valid.
48268 // SAFETY: We never touch this element again after dropped.
48274 // SAFETY: `deleted_cnt` > 0, so the hole slot must not overlap with current element.
48275 // We use copy for move, and never touch this element again.
48342 /* Offset of the element we want to check if it is duplicate */
48425 /// Appends an element to the back of a collection.
48453 /// Removes the last element from a vector and returns it, or [`None`] if it
48862 // - `spare_ptr` is pointing one element past the buffer, so it doesn't overlap with `initialized`
48908 /// Iterates over the slice `other`, clones each element, and then appends
48962 // This code generalizes `extend_with_{element,default}`.
49019 // We can write the last element directly without cloning needlessly
49089 // - len is increased after each element to prevent leaks (see issue #82533)
49307 while let Some(element) = iterator.next() {
49314 ptr::write(self.as_mut_ptr().add(len), element);
49364 /// Creates an iterator which uses a closure to determine if an element should be removed.
49366 /// If the closure returns true, then the element is removed and yielded.
49367 /// If the closure returns false, the element will remain in the vector and will not be yielded
49391 /// Note that `drain_filter` also lets you mutate every element in the filter closure,
49740 /// An iterator which uses a closure to determine if an element should be removed.
49808 // is updated prior and the predicate panics, the element at this