This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func TestPriorityQueue(t *testing.T) { | |
| pq := NewPriorityQueue() | |
| val := &struct{}{} | |
| var wg sync.WaitGroup | |
| const nthreads = 32 | |
| for range nthreads { | |
| wg.Add(1) | |
| go func() { | |
| for range 100_000 { | |
| pq.Put(1, 1, val) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for { | |
| time.Sleep(interval) | |
| if ws.killClock.Add(1) > createDelay && nworkers.Load() > minWorkers { | |
| ws.ch <- task{} // send poison pill to one worker | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| timer := time.NewTimer(timeout) | |
| for { | |
| select { | |
| case task = <-ws.ch: | |
| if !timer.Stop() { | |
| <-timer.C | |
| } | |
| timer.Reset(timeout) | |
| run(task) | |
| case <-timer.C: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Hmap[K any, V any, H helper[K]] struct { | |
| help H | |
| // ... | |
| } | |
| type helper[K any] interface { | |
| Hash(k K) uint64 | |
| Equal(x, y K) bool | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package runtime | |
| import "testing" | |
| type intfc interface { | |
| f() intfc | |
| } | |
| type byval struct { | |
| x int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #pragma once | |
| /* | |
| * Hmap and Hset are hash based maps and sets | |
| * implemented with: prime table sizes, open addressing, linear probing, | |
| * robin hood hashing, and resize on probe limit. | |
| * Htbl is the common code, it is not intended for external use. | |
| * To avoid padding it uses an array of blocks each with BN (4) entries. | |
| * But we still treat it as a single flat array. | |
| * Within blocks keys, values, and distances are separate arrays to avoid padding. | |
| * Uses uint16 for size so limited to 64k slots or about 48k elements. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class | |
| { | |
| CallClass(@args) | |
| { | |
| ai = 0 | |
| fi = 1 | |
| mixed = args[1..].Map({ it is Bind ? 'a' $ ai++ : '.f' $ fi++ }).Join(',') | |
| c = (.binder)(mixed) | |
| return c(@args.Remove(Bind)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function (@args) | |
| { | |
| helper = class | |
| { | |
| New(.args) | |
| { } | |
| Call(@args2) | |
| { | |
| args = .args | |
| if not args2.Empty?() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <script src="http://codemirror.net/lib/codemirror.js"></script> | |
| <link rel="stylesheet" href="http://codemirror.net/lib/codemirror.css"> | |
| <script type="text/javascript"> | |
| window.onload = function () { | |
| CodeMirror(document.body); | |
| }; | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func TestIs(t *testing.T) { | |
| cm := Is('x') | |
| Assert(t).That(cm.Match('x'), Equals(true)) | |
| Assert(t).That(cm.Match('y'), Equals(false)) | |
| } | |
| func TestAnyOf(t *testing.T) { | |
| cm := AnyOf("abc") | |
| Assert(t).That(cm.Match('b'), Equals(true)) | |
| Assert(t).That(cm.Match('x'), Equals(false)) |
NewerOlder