mirror of
https://github.com/vlang/v.git
synced 2025-09-16 07:52:32 +03:00
checker: unsafe 0 for references (default value)
This commit is contained in:
parent
546f9a544f
commit
e76f74fd73
12 changed files with 28 additions and 22 deletions
|
@ -9,13 +9,13 @@ mut:
|
|||
// Value of the node
|
||||
value T
|
||||
// The parent of the node
|
||||
parent &BSTreeNode<T> = 0
|
||||
parent &BSTreeNode<T> = unsafe { 0 }
|
||||
// The left side with value less than the
|
||||
// value of this node
|
||||
left &BSTreeNode<T> = 0
|
||||
left &BSTreeNode<T> = unsafe { 0 }
|
||||
// The right side with value grater than the
|
||||
// value of thiss node
|
||||
right &BSTreeNode<T> = 0
|
||||
right &BSTreeNode<T> = unsafe { 0 }
|
||||
}
|
||||
|
||||
// Create new root bst node
|
||||
|
@ -61,7 +61,7 @@ fn (mut node BSTreeNode<T>) bind(mut to_bind BSTreeNode<T>, left bool) {
|
|||
// Space complexity O(N)
|
||||
pub struct BSTree<T> {
|
||||
mut:
|
||||
root &BSTreeNode<T> = 0
|
||||
root &BSTreeNode<T> = unsafe { 0 }
|
||||
}
|
||||
|
||||
// insert give the possibility to insert an element in the BST.
|
||||
|
|
|
@ -3,18 +3,18 @@ module datatypes
|
|||
struct DoublyListNode<T> {
|
||||
mut:
|
||||
data T
|
||||
next &DoublyListNode<T> = 0
|
||||
prev &DoublyListNode<T> = 0
|
||||
next &DoublyListNode<T> = unsafe { 0 }
|
||||
prev &DoublyListNode<T> = unsafe { 0 }
|
||||
}
|
||||
|
||||
pub struct DoublyLinkedList<T> {
|
||||
mut:
|
||||
head &DoublyListNode<T> = 0
|
||||
tail &DoublyListNode<T> = 0
|
||||
head &DoublyListNode<T> = unsafe { 0 }
|
||||
tail &DoublyListNode<T> = unsafe { 0 }
|
||||
// Internal iter pointer for allowing safe modification
|
||||
// of the list while iterating. TODO: use an option
|
||||
// instead of a pointer to determine it is initialized.
|
||||
iter &DoublyListIter<T> = 0
|
||||
iter &DoublyListIter<T> = unsafe { 0 }
|
||||
len int
|
||||
}
|
||||
|
||||
|
@ -280,5 +280,5 @@ pub fn (mut list DoublyLinkedList<T>) next() ?T {
|
|||
|
||||
struct DoublyListIter<T> {
|
||||
mut:
|
||||
node &DoublyListNode<T> = 0
|
||||
node &DoublyListNode<T> = unsafe { 0 }
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ module datatypes
|
|||
pub struct ListNode<T> {
|
||||
mut:
|
||||
data T
|
||||
next &ListNode<T> = 0
|
||||
next &ListNode<T> = unsafe { 0 }
|
||||
}
|
||||
|
||||
pub struct LinkedList<T> {
|
||||
mut:
|
||||
head &ListNode<T> = 0
|
||||
head &ListNode<T> = unsafe { 0 }
|
||||
len int
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue