<commit_before>use super::{Dimension, Ix};

/// An iterator of the indexes of an array shape.
///
/// Iterator element type is `D`.
#[derive(Clone)]
pub struct Indexes<D> {
    dim: D,
    index: Option<D>,
}

impl<D: Dimension> Indexes<D>
{
    /// Create an iterator over the array shape `dim`.
    pub fn new(dim: D) -> Indexes<D>
    {
        Indexes {
            index: dim.first_index(),
            dim: dim,
        }
    }
}

/// Like `range`, except with array indexes.
#[inline]
pub fn ixrange(a: Ix, b: Ix) -> Indexes<Ix>
{
    Indexes {
        index: if a >= b { None } else { Some(a) },
        dim: b,
    }
}

impl Indexes<()>
{
    /// Create an iterator over the array shape `a`.
    pub fn new1(a: Ix) -> Indexes<Ix>
    {
        Indexes {
            index: a.first_index(),
            dim: a,
        }
    }

    /// Create an iterator over the array shape `(a, b)`.
    pub fn new2(a: Ix, b: Ix) -> Indexes<(Ix, Ix)>
    {
        Indexes {
            index: (a, b).first_index(),
            dim: (a, b),
        }
    }

    /// Create an iterator over the array shape `(a, b, c)`.
    pub fn new3(a: Ix, b: Ix, c: Ix) -> Indexes<(Ix, Ix, Ix)>
    {
        Indexes {
            index: (a, b, c).first_index(),
            dim: (a, b, c),
        }
    }
}


impl<D: Dimension> Iterator for Indexes<D>
{
    type Item = D;
    #[inline]
    fn next(&mut self) -> Option<D>
    {
        let index = match self.index {
            None => return None,
            Some(ref ix) => ix.clone(),
        };
        self.index = self.dim.next_for(index.clone());
        Some(index)
    }

    fn size_hint(&self) -> (usize, Option<usize>)
    {
        let l = match self.index {<commit_msg>Mark certain Indexes constructors as deprecated.<commit_after>use super::{Dimension, Ix};

/// An iterator of the indexes of an array shape.
///
/// Iterator element type is `D`.
#[derive(Clone)]
pub struct Indexes<D> {
    dim: D,
    index: Option<D>,
}

impl<D: Dimension> Indexes<D>
{
    /// Create an iterator over the array shape `dim`.
    pub fn new(dim: D) -> Indexes<D>
    {
        Indexes {
            index: dim.first_index(),
            dim: dim,
        }
    }
}

/// Like `range`, except with array indexes.
///
/// **Deprecated, use ranges instead.**
#[inline]
pub fn ixrange(a: Ix, b: Ix) -> Indexes<Ix>
{
    Indexes {
        index: if a >= b { None } else { Some(a) },
        dim: b,
    }
}

impl Indexes<()>
{
    /// Create an iterator over the array shape `a`.
    ///
    /// **Deprecated**
    pub fn new1(a: Ix) -> Indexes<Ix>
    {
        Indexes {
            index: a.first_index(),
            dim: a,
        }
    }

    /// Create an iterator over the array shape `(a, b)`.
    ///
    /// **Deprecated**
    pub fn new2(a: Ix, b: Ix) -> Indexes<(Ix, Ix)>
    {
        Indexes {
            index: (a, b).first_index(),
            dim: (a, b),
        }
    }

    /// Create an iterator over the array shape `(a, b, c)`.
    ///
    /// **Deprecated**
    pub fn new3(a: Ix, b: Ix, c: Ix) -> Indexes<(Ix, Ix, Ix)>
    {
        Indexes {
            index: (a, b, c).first_index(),
            dim: (a, b, c),
        }
    }
}


impl<D: Dimension> Iterator for Indexes<D>
{
    type Item = D;
    #[inline]
    fn next(&mut self) -> Option<D>
    {
        let index = match self.index {
            None => return None,
            Some(ref ix) => ix.clone(),
        };
        self.index = self.dim.next_for(index.clone());
        Some(index)
    }

    fn size_hint(&self) -> (usize, Option<usize>)
    {
        let l = match self.index {
{'fraction_non_alphanumeric': 0.16546563192904656, 'fraction_numerical': 0.0016629711751662971, 'mean_word_length': 1.6634686346863468, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7436578', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1283, 'n_words': 368}