1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2019 Octavian Oncescu

use crate::vertex_id::VertexId;

#[derive(Debug)]
pub struct VertexIter<'a> {
    current: usize,
    iterable: Vec<&'a VertexId>
}

impl<'a> VertexIter<'a> {
    pub fn new(neighbors: Vec<&'a VertexId>) -> VertexIter<'a> {
        VertexIter {
            current: 0,
            iterable: neighbors
        }
    }
}

impl<'a> Iterator for VertexIter<'a> {
    type Item = &'a VertexId;

    fn next(&mut self) -> Option<Self::Item> {
        if self.current == self.iterable.len() {
            return None;
        } 
        
        let result = self.iterable[self.current];
        self.current += 1;

        Some(result)
    }
}