diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-25 23:08:47 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:52 +0100 |
| commit | db469da2704f703d15e81f5e44ba157c10a21e77 (patch) | |
| tree | 2f5b21600ed07b900b141aa910a9b2d6a1dfd4a3 /go/utils | |
| parent | 7f271376d192b95e072750411970768782e75a63 (diff) | |
| download | muhqs-game-db469da2704f703d15e81f5e44ba157c10a21e77.tar.gz muhqs-game-db469da2704f703d15e81f5e44ba157c10a21e77.zip | |
intermediate commit
* Implement move artifact action
* Fix widget update memory leak
* update the highlights not during on each frame
* do not update the unchanged label of a button
* Allow to exit the game by pressing 'q'
* Implement some cards from the magic set
* Improve permanent formatting
* Some tweaks to UnitAI code
Diffstat (limited to 'go/utils')
| -rw-r--r-- | go/utils/slices.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/go/utils/slices.go b/go/utils/slices.go index 3cc38c1c..eb02f782 100644 --- a/go/utils/slices.go +++ b/go/utils/slices.go @@ -15,3 +15,16 @@ func InterfaceSliceToTypedSlice[T any](s []interface{}) []T { } return ts } + +func RemoveFromUnorderedSlice[T comparable](s []T, o T) []T { + for i, t := range s { + if t != o { + continue + } + + s[i] = s[len(s) - 1] + return s[:len(s) - 1] + } + + return s +} |
