This file contains 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 main | |
import ( | |
"fmt" | |
"math/rand" | |
"runtime" | |
) | |
func main() { | |
BoolImplMemoryFootprint() |
This file contains 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 insert | |
import ( | |
"fmt" | |
"testing" | |
"golang.org/x/exp/slices" | |
) | |
func BenchmarkGrow(b *testing.B) { |
This file contains 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 insert | |
import ( | |
"fmt" | |
"testing" | |
"golang.org/x/exp/slices" | |
) | |
func BenchmarkGrow(b *testing.B) { |
This file contains 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 bench | |
import ( | |
"testing" | |
"golang.org/x/exp/slices" | |
) | |
func BenchmarkRemoveFirstByValue(b *testing.B) { | |
items := []string{"a", "b", "c", "d", "e", "f", "g", "h"} |
This file contains 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 delete | |
import ( | |
"fmt" | |
"testing" | |
"golang.org/x/exp/slices" | |
) | |
func BenchmarkDeleteLast(b *testing.B) { |
This file contains 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
main() { | |
final items = ['a', 'b']; | |
items.asMap().forEach((i, x) { | |
print('index=$i, value=$x'); | |
}); | |
} |
This file contains 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
import 'package:collection/collection.dart'; | |
main() { | |
final items = ['a', 'b']; | |
items.forEachIndexed((i, x) { | |
print('index=$i, value=$x'); | |
}); | |
} |
This file contains 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
import 'package:collection/collection.dart'; | |
main() { | |
final items = ['a', 'b']; | |
items.forEachIndexed((i, value) { | |
print('index=$i, value=$value'); | |
}); | |
} |
This file contains 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 slices | |
import "testing" | |
func delete[S ~[]E, E any](s S, i, j int) S { | |
_ = s[i:j] // bound check | |
return append(s[:i], s[j:]...) | |
} |
This file contains 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
void main() { | |
var i = 123; | |
var s = "$i"; | |
print("String s has value: [" + s + "]"); | |
} |