Skip to content

Commit

Permalink
๐Ÿฆ„ refactor(rust/deque): change LinkedList to VecDeque (krahets#364)
Browse files Browse the repository at this point in the history
* ๐Ÿฆ„ refactor(deque):  change LinkedList to VecDeque

* ๐Ÿ“ƒ docs(deque): add author

* ๐Ÿฆ„ refactor(rust/queue):  change LinkedList to VecDeque

* ๐Ÿ“ƒ docs(rust/queue): add author

* ๐Ÿ“ƒ docs(deque): corrent author format
  • Loading branch information
xBLACKICEx authored Feb 15, 2023
1 parent f0b092f commit 1209261
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions codes/rust/chapter_stack_and_queue/deque.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* File: deque.rs
* Created Time: 2023-02-05
* Author: sjinzh ([email protected])
* Author: sjinzh ([email protected]), xBLACKICEx ([email protected])
*/

include!("../include/include.rs");

use std::collections::LinkedList;
use std::collections::VecDeque;

/* Driver Code */
pub fn main() {
// ๅˆๅง‹ๅŒ–ๅŒๅ‘้˜Ÿๅˆ—
let mut deque: LinkedList<i32> = LinkedList::new();
let mut deque: VecDeque<i32> = VecDeque::new();
deque.push_back(2); // ๆทปๅŠ ่‡ณ้˜Ÿๅฐพ
deque.push_back(5);
deque.push_back(4);
Expand Down
6 changes: 3 additions & 3 deletions codes/rust/chapter_stack_and_queue/queue.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* File: queue.rs
* Created Time: 2023-02-05
* Author: sjinzh ([email protected])
* Author: sjinzh ([email protected]), xBLACKICEx ([email protected])
*/

include!("../include/include.rs");

use std::collections::LinkedList;
use std::collections::VecDeque;

/* Driver Code */
pub fn main() {
// ๅˆๅง‹ๅŒ–้˜Ÿๅˆ—
let mut queue: LinkedList<i32> = LinkedList::new();
let mut queue: VecDeque<i32> = VecDeque::new();

// ๅ…ƒ็ด ๅ…ฅ้˜Ÿ
queue.push_back(1);
Expand Down
6 changes: 3 additions & 3 deletions codes/rust/include/print_util.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* File: print_util.rs
* Created Time: 2023-02-05
* Author: sjinzh ([email protected])
* Author: sjinzh ([email protected]), xBLACKICEx ([email protected])
*/

use std::fmt::Display;
use std::collections::{HashMap, LinkedList};
use std::collections::{HashMap, VecDeque};

/* Print an array */
pub fn print_array<T: Display>(nums: &[T]) {
Expand All @@ -27,7 +27,7 @@ pub fn print_hash_map<TKey: Display, TValue: Display>(map: &HashMap<TKey, TValue
}

/* Print a queue or deque */
pub fn print_queue<T: Display>(queue: &LinkedList<T>) {
pub fn print_queue<T: Display>(queue: &VecDeque<T>) {
print!("[");
let iter = queue.iter();
for (i, data) in iter.enumerate() {
Expand Down

0 comments on commit 1209261

Please sign in to comment.