mirror of
https://github.com/krahets/hello-algo.git
synced 2026-02-03 10:53:35 +08:00
* Review the EN heading format. * Fix pythontutor headings. * Fix pythontutor headings. * bug fixes * Fix headings in **/summary.md * Revisit the CN-to-EN translation for Python code using Claude-4.5 * Revisit the CN-to-EN translation for Java code using Claude-4.5 * Revisit the CN-to-EN translation for Cpp code using Claude-4.5. * Fix the dictionary. * Fix cpp code translation for the multipart strings. * Translate Go code to English. * Update workflows to test EN code. * Add EN translation for C. * Add EN translation for CSharp. * Add EN translation for Swift. * Trigger the CI check. * Revert. * Update en/hash_map.md * Add the EN version of Dart code. * Add the EN version of Kotlin code. * Add missing code files. * Add the EN version of JavaScript code. * Add the EN version of TypeScript code. * Fix the workflows. * Add the EN version of Ruby code. * Add the EN version of Rust code. * Update the CI check for the English version code. * Update Python CI check. * Fix cmakelists for en/C code. * Fix Ruby comments
42 lines
1.0 KiB
Rust
42 lines
1.0 KiB
Rust
/*
|
|
* File: queue.rs
|
|
* Created Time: 2023-02-05
|
|
* Author: codingonion (coderonion@gmail.com), xBLACKICEx (xBLACKICEx@outlook.com)
|
|
*/
|
|
|
|
use hello_algo_rust::include::print_util;
|
|
|
|
use std::collections::VecDeque;
|
|
|
|
/* Driver Code */
|
|
pub fn main() {
|
|
// Access front of the queue element
|
|
let mut queue: VecDeque<i32> = VecDeque::new();
|
|
|
|
// Elements enqueue
|
|
queue.push_back(1);
|
|
queue.push_back(3);
|
|
queue.push_back(2);
|
|
queue.push_back(5);
|
|
queue.push_back(4);
|
|
print!("Queue queue = ");
|
|
print_util::print_queue(&queue);
|
|
|
|
// Return list for printing
|
|
let peek = queue.front().unwrap();
|
|
println!("\nFront element peek = {peek}");
|
|
|
|
// Element dequeue
|
|
let pop = queue.pop_front().unwrap();
|
|
print!("Dequeue element pop = {pop}, after dequeue queue = ");
|
|
print_util::print_queue(&queue);
|
|
|
|
// Get the length of the queue
|
|
let size = queue.len();
|
|
print!("\nQueue length size = {size}");
|
|
|
|
// Check if the queue is empty
|
|
let is_empty = queue.is_empty();
|
|
print!("\nIs queue empty = {is_empty}");
|
|
}
|