Created
May 27, 2022 17:43
-
-
Save matthewcrews/8e9f290e3aad6b0c6efb2bdc493b6c5b to your computer and use it in GitHub Desktop.
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
[<Struct;IsByRefLike>] | |
type StackStack<'T>(values: Span<'T>) = | |
[<DefaultValue>] val mutable private Count : int | |
member s.Push v = | |
if s.Count < values.Length then | |
values[s.Count] <- v | |
s.Count <- s.Count + 1 | |
else | |
failwith "Exceeded capacity of StackStack" | |
member s.Pop () = | |
if s.Count > 0 then | |
s.Count <- s.Count - 1 | |
values[s.Count] | |
else | |
failwith "Empty StackStack" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment