forked from krahets/hello-algo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
๐ฆ refactor(rust/deque): change LinkedList to VecDeque (krahets#364)
* ๐ฆ 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
1 parent
f0b092f
commit 1209261
Showing
3 changed files
with
9 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) { | ||
|
@@ -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() { | ||
|