mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-14 16:35:03 +01:00
restore list
This commit is contained in:
parent
f9e07b376b
commit
179c4b3505
1 changed files with 20 additions and 20 deletions
40
std/list.nil
40
std/list.nil
|
|
@ -1,21 +1,21 @@
|
|||
//type List[T] = struct {
|
||||
// ptr: Int,
|
||||
// len: Int,
|
||||
// cap: Int,
|
||||
//};
|
||||
//
|
||||
//function new(): List[Int] = (
|
||||
// List { ptr: 0, len: 0, cap: 0 }
|
||||
//);
|
||||
//
|
||||
//function push(list: List[Int], elem: Int) = (
|
||||
// growIfNeeded(list, 1);
|
||||
//);
|
||||
//
|
||||
type List[T] = struct {
|
||||
ptr: Int,
|
||||
len: Int,
|
||||
cap: Int,
|
||||
};
|
||||
|
||||
function new(): List[Int] = (
|
||||
List { ptr: 0, len: 0, cap: 0 }
|
||||
);
|
||||
|
||||
function push(list: List[Int], elem: Int) = (
|
||||
growIfNeeded(list, 1);
|
||||
);
|
||||
|
||||
// PRIVATE:
|
||||
//
|
||||
//function growIfNeeded(list: List[Int], elems: Int) = (
|
||||
// if (list.len + elems) < list.cap then (
|
||||
// let newMemory = std.rt.alloc.allocateItem(0_I32, 0_I32);
|
||||
// );
|
||||
//);
|
||||
|
||||
function growIfNeeded(list: List[Int], elems: Int) = (
|
||||
if (list.len + elems) < list.cap then (
|
||||
let newMemory = std.rt.alloc.allocateItem(0_I32, 0_I32);
|
||||
);
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue