1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/adt
2021-12-24 11:19:40 +02:00
..
doubly_linked_list_test.v adt: implement a doubly linked list (#12950) 2021-12-24 11:19:40 +02:00
doubly_linked_list.v adt: implement a doubly linked list (#12950) 2021-12-24 11:19:40 +02:00
linked_list_test.v adt: add linked list (#12937) 2021-12-23 18:23:04 +02:00
linked_list.v adt: add linked list (#12937) 2021-12-23 18:23:04 +02:00
queue_test.v adt: add queue (#12941) 2021-12-23 18:57:15 +02:00
queue.v adt: add queue (#12941) 2021-12-23 18:57:15 +02:00
README.md adt: add queue (#12941) 2021-12-23 18:57:15 +02:00
stack_test.v vlib: add an adt module (Abstract Data Types) (#12901) 2021-12-23 15:16:29 +02:00
stack.v vlib: add an adt module (Abstract Data Types) (#12901) 2021-12-23 15:16:29 +02:00

datatypes

This module provides implementations of less frequently used, but still common data types.

V's builtin module is imported implicitly, and has implementations for arrays, maps and strings. These are good for many applications, but there are a plethora of other useful data structures/containers, like linked lists, priority queues, tries, etc, that allow for algorithms with different time complexities, which may be more suitable for your specific application.

It is implemented using generics, that you have to specialise for the type of your actual elements. For example:

import adt

mut stack := adt.Stack<int>{}
stack.push(1)
println(stack)

Currently Implemented Datatypes:

  • Linked list
  • Stack (LIFO)
  • Queue (FIFO)
  • ...