Created
February 1, 2023 00:35
-
-
Save CollinShoop/973ff9d5276008716293dd73b6b2b91a to your computer and use it in GitHub Desktop.
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
type OrderedStream struct { | |
index int | |
values []string | |
} | |
func Constructor(n int) OrderedStream { | |
return OrderedStream { | |
index: 0, | |
values: make([]string, n), | |
} | |
} | |
func (this *OrderedStream) Insert(idKey int, value string) []string { | |
this.values[idKey-1] = value | |
ret := []string{} | |
for this.index < len(this.values) && this.values[this.index] != "" { | |
ret = append(ret, this.values[this.index]) | |
this.index++ | |
} | |
return ret | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment