1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

vlib: rename adt to datatypes

This commit is contained in:
Delyan Angelov 2021-12-26 16:01:36 +02:00
parent 2210f89ea3
commit 8a10dbcf27
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
11 changed files with 19 additions and 19 deletions

View File

@ -12,9 +12,9 @@ be more suitable for your specific application.
It is implemented using generics, that you have to specialise for the type of It is implemented using generics, that you have to specialise for the type of
your actual elements. For example: your actual elements. For example:
```v ```v
import adt import datatypes
mut stack := adt.Stack<int>{} mut stack := datatypes.Stack<int>{}
stack.push(1) stack.push(1)
println(stack) println(stack)
``` ```

View File

@ -1,4 +1,4 @@
module adt module datatypes
struct DoublyListNode<T> { struct DoublyListNode<T> {
mut: mut:

View File

@ -1,4 +1,4 @@
module adt module datatypes
fn test_is_empty() { fn test_is_empty() {
mut list := DoublyLinkedList<int>{} mut list := DoublyLinkedList<int>{}

View File

@ -1,4 +1,4 @@
module adt module datatypes
// MinHeap is a binary minimum heap data structure. // MinHeap is a binary minimum heap data structure.
pub struct MinHeap<T> { pub struct MinHeap<T> {

View File

@ -1,4 +1,4 @@
module adt module datatypes
fn test_min_heap() ? { fn test_min_heap() ? {
mut heap := MinHeap<int>{} mut heap := MinHeap<int>{}

View File

@ -1,4 +1,4 @@
module adt module datatypes
pub struct ListNode<T> { pub struct ListNode<T> {
mut: mut:

View File

@ -1,4 +1,4 @@
module adt module datatypes
fn test_is_empty() { fn test_is_empty() {
mut list := LinkedList<int>{} mut list := LinkedList<int>{}

View File

@ -1,4 +1,4 @@
module adt module datatypes
pub struct Queue<T> { pub struct Queue<T> {
mut: mut:

View File

@ -1,4 +1,4 @@
module adt module datatypes
fn test_is_empty() { fn test_is_empty() {
mut queue := Queue<int>{} mut queue := Queue<int>{}

View File

@ -1,4 +1,4 @@
module adt module datatypes
pub struct Stack<T> { pub struct Stack<T> {
mut: mut:

View File

@ -1,14 +1,14 @@
import adt import datatypes as dt
fn test_is_empty() { fn test_is_empty() {
mut stack := adt.Stack<int>{} mut stack := dt.Stack<int>{}
assert stack.is_empty() == true assert stack.is_empty() == true
stack.push(1) stack.push(1)
assert stack.is_empty() == false assert stack.is_empty() == false
} }
fn test_len() ? { fn test_len() ? {
mut stack := adt.Stack<int>{} mut stack := dt.Stack<int>{}
assert stack.len() == 0 assert stack.len() == 0
stack.push(1) stack.push(1)
assert stack.len() == 1 assert stack.len() == 1
@ -17,18 +17,18 @@ fn test_len() ? {
} }
fn test_peek() ? { fn test_peek() ? {
mut stack := adt.Stack<int>{} mut stack := dt.Stack<int>{}
stack.push(1) stack.push(1)
assert stack.peek() ? == 1 assert stack.peek() ? == 1
stack.push(2) stack.push(2)
assert stack.peek() ? == 2 assert stack.peek() ? == 2
stack = adt.Stack<int>{} stack = dt.Stack<int>{}
stack.peek() or { return } stack.peek() or { return }
assert false assert false
} }
fn test_push() ? { fn test_push() ? {
mut stack := adt.Stack<int>{} mut stack := dt.Stack<int>{}
stack.push(1) stack.push(1)
assert stack.peek() ? == 1 assert stack.peek() ? == 1
stack.push(2) stack.push(2)
@ -38,7 +38,7 @@ fn test_push() ? {
} }
fn test_pop() ? { fn test_pop() ? {
mut stack := adt.Stack<int>{} mut stack := dt.Stack<int>{}
stack.push(1) stack.push(1)
stack.push(2) stack.push(2)
stack.push(3) stack.push(3)
@ -46,7 +46,7 @@ fn test_pop() ? {
stack.push(4) stack.push(4)
assert stack.pop() ? == 4 assert stack.pop() ? == 4
assert stack.pop() ? == 2 assert stack.pop() ? == 2
stack = adt.Stack<int>{} stack = dt.Stack<int>{}
stack.pop() or { return } stack.pop() or { return }
assert false assert false
} }