use crate::{linked_list::LinkedList, node::LinkedListNode};
use orx_imp_vec::prelude::PinnedVec;
impl<'a, T, P> LinkedList<'a, T, P>
where
P: PinnedVec<LinkedListNode<'a, T>> + 'a,
T: PartialEq,
{
/// Returns `true` if the `LinkedList` contains an element equal to the
/// given value.
///
/// This operation should compute linearly in *O*(*n*) time.
///
/// # Examples
///
/// ```
/// use orx_linked_list::prelude::*;
///
/// let mut list = LinkedList::with_doubling_growth(8);
/// list.push_back(0);
/// list.push_back(1);
/// list.push_back(2);
///
/// assert_eq!(list.contains(&0), true);
/// assert_eq!(list.contains(&10), false);
/// ```
pub fn contains(&'a self, x: &T) -> bool {
self.iter().any(|e| e == x)
}
}