pub fn shuffle(&self) -> Vec<&PathBuf> {
        let mut list: Vec<&PathBuf> = vec![];
        if self.tree.is_empty() {
            return list;
        }
        let mut len: usize = 0;
        let mut rng = rand::thread_rng();
        // Add all songs from each band (shuffled artisti-wise), and find the maximum number of songs for one band
        self.tree.iter().for_each(|(_, v)| {
            if len < v.len() {
                len = v.len();
            }
            let start = list.len();
            list.extend(v.iter());
            list[start..].shuffle(&mut rng);
        });
        if list.is_empty() {
            return list;
        }
        // Reorder the list so that the songs from the same band are spread out
        let mut list: Vec<&PathBuf> = sample(&mut rng, len, len)
            .into_iter()
            .flat_map(|i| list.iter().skip(i).step_by(len))
            .map(|p| *p)
            .collect();
        // Do some local randomisation (to not always have the same order of artists)
        let stride: usize = (list.len() * 2) / (len * 5) + 1;
        list.chunks_mut(stride).for_each(|c| c.shuffle(&mut rng));
        list
    }
// Create a list of all songs in the filemap, and so a artist-aware shuffle
Create a list of all songs in the filemap, and so a artist-aware shuffle
Create a list of all songs in the filemap and so a artist - aware shuffle
pub fn shuffle(&self) -> Vec<&PathBuf> {
        let mut list: Vec<&PathBuf> = vec![];
        if self.tree.is_empty() {
            return list;
        }
        let mut len: usize = 0;
        let mut rng = rand::thread_rng();
        // Add all songs from each band (shuffled artisti-wise), and find the maximum number of songs for one band
        self.tree.iter().for_each(|(_, v)| {
            if len < v.len() {
                len = v.len();
            }
            let start = list.len();
            list.extend(v.iter());
            list[start..].shuffle(&mut rng);
        });
        if list.is_empty() {
            return list;
        }
        // Reorder the list so that the songs from the same band are spread out
        let mut list: Vec<&PathBuf> = sample(&mut rng, len, len)
            .into_iter()
            .flat_map(|i| list.iter().skip(i).step_by(len))
            .map(|p| *p)
            .collect();
        // Do some local randomisation (to not always have the same order of artists)
        let stride: usize = (list.len() * 2) / (len * 5) + 1;
        list.chunks_mut(stride).for_each(|c| c.shuffle(&mut rng));
        list
    }
pub fn shuffle ( & self ) -> Vec < & PathBuf > { let mut list : Vec < & PathBuf > = vec ! [ ] ; if self . tree . is_empty ( ) { return list ; } let mut len : usize = 0 ; let mut rng = rand :: thread_rng ( ) ; // Add all songs from each band (shuffled artisti-wise), and find the maximum number of songs for one band self . tree . iter ( ) . for_each ( | ( _ , v ) | { if len < v . len ( ) { len = v . len ( ) ; } let start = list . len ( ) ; list . extend ( v . iter ( ) ) ; list [ start .. ] . shuffle ( & mut rng ) ; } ) ; if list . is_empty ( ) { return list ; } // Reorder the list so that the songs from the same band are spread out let mut list : Vec < & PathBuf > = sample ( & mut rng , len , len ) . into_iter ( ) . flat_map ( | i | list . iter ( ) . skip ( i ) . step_by ( len ) ) . map ( | p | * p ) . collect ( ) ; // Do some local randomisation (to not always have the same order of artists) let stride : usize = ( list . len ( ) * 2 ) / ( len * 5 ) + 1 ; list . chunks_mut ( stride ) . for_each ( | c | c . shuffle ( & mut rng ) ) ; list }
Create a list of all songs in the filemap, and so a artist-aware shuffle
Create a list of all songs in the filemap and so a artist - aware shuffle
&self
&self