Files
adler32
ansi_term
atty
backtrace
backtrace_sys
bitflags
byteorder
cfg_if
clap
app
args
completions
color_quant
crossbeam_deque
crossbeam_epoch
crossbeam_queue
crossbeam_utils
deflate
either
event_loop
failure
failure_derive
float
fnv
gif
gl
graphics
glyph_cache
image
bmp
hdr
ico
imageops
jpeg
math
pnm
tga
utils
webp
inflate
input
interpolation
jpeg_decoder
lazy_static
libc
unix
lzw
memoffset
num
num_cpus
num_derive
num_integer
num_iter
num_rational
num_traits
opengl_graphics
piston
png
rand
distributions
prng
rngs
rayon
collections
compile_fail
iter
chain.rschunks.rscloned.rscopied.rsempty.rsenumerate.rsextend.rsfilter.rsfilter_map.rsfind.rsflat_map.rsflatten.rsfold.rsfor_each.rsfrom_par_iter.rsinspect.rsinterleave.rsinterleave_shortest.rsintersperse.rslen.rsmap.rsmap_with.rsmod.rsmultizip.rsnoop.rsonce.rspanic_fuse.rspar_bridge.rsproduct.rsreduce.rsrepeat.rsrev.rsskip.rssplitter.rssum.rstake.rstry_fold.rstry_reduce.rstry_reduce_with.rsunzip.rsupdate.rswhile_some.rszip.rszip_eq.rs
slice
rayon_core
compile_fail
join
scope
sleep
spawn
thread_pool
read_color
rustc_demangle
scoped_threadpool
scopeguard
sdl2
sdl2_sys
sdl2_window
serde
de
private
ser
serde_derive
shader_version
shaders_graphics2d
sorting_visualization
algorithms
strsim
synstructure
texture
textwrap
tiff
unicode_width
vec_map
vecmath
viewport
window
>
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
//! [Gnome sort](https://en.wikipedia.org/wiki/Gnome_sort) use super::{Algorithm, Array}; /// [Gnome sort](https://en.wikipedia.org/wiki/Gnome_sort) pub struct GnomeSort; impl Algorithm for GnomeSort { fn sort(&self, array: Array) { let len = array.len(); let mut i = 0; while i < len { array.set_color(i, [0.0, 1.0, 0.0, 0.8]); array.wait(5); array.reset_color(i); if i == 0 || array.get(i) >= array.get(i - 1) { i += 1; } else { array.swap(i, i - 1); i -= 1; } } } fn name(&self) -> String { "Gnome sort".to_string() } }