mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
* lib/std/sort: unify binarysearch and binarysearch_with; add comments to quicksort Signed-off-by: Pierre Curto <pierre.curto@gmail.com> * lib/std/collections: mark List.{len, is_empty, get} with @inline Signed-off-by: Pierre Curto <pierre.curto@gmail.com> * lib/std/collections: add PriorityQueueMax; add tests for PriorityQueue and PriorityQueueMax Signed-off-by: Pierre Curto <pierre.curto@gmail.com> --------- Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
32 lines
472 B
C
32 lines
472 B
C
// #target: macos-x64
|
|
module test;
|
|
import std::io;
|
|
import std::math;
|
|
import std::collections::priorityqueue;
|
|
|
|
def FooPriorityQueue = PriorityQueueMax(<Foo>);
|
|
|
|
fn void main()
|
|
{
|
|
|
|
FooPriorityQueue agh;
|
|
agh.push(Foo { 3 });
|
|
agh.push(Foo { 101 });
|
|
agh.push(Foo { 10 });
|
|
while (try f = agh.pop()) io::printf("%s\n", f.x);
|
|
}
|
|
|
|
struct Foo
|
|
{
|
|
int x;
|
|
}
|
|
|
|
fn bool Foo.less(Foo* x, Foo y) @inline
|
|
{
|
|
return x.x < y.x;
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
%PrivatePriorityQueue = type { %List }
|