-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Strongly type ApiVersion and SdkVersion (#3753)
- Rename `packageGenerator.apiVersion` to `packageGenerator.sdkVersion`. - Rename `packageGenerator.allApiVersions` to `packageGenerator.allSdkVersions`. - Add packageGenerator.apiVersion as pointer to an ApiVersion, if we can convert it. - Add `collections.OrderableSet` as replacement for `codegen.StringSet` which allows for non-string types. - Document where a string can be either API or SDK versions and is therefore remaining a string for now. - Fix type mismatch in `ShouldInclude` with the RemovedVersions file which included removed versions in the description.
- Loading branch information
1 parent
5a1321b
commit 04edaa3
Showing
1,286 changed files
with
2,031 additions
and
2,782 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package collections | ||
|
||
import ( | ||
"cmp" | ||
"slices" | ||
) | ||
|
||
func OrderedKeys[T cmp.Ordered](m map[T]any) []T { | ||
keys := make([]T, 0, len(m)) | ||
for key := range m { | ||
keys = append(keys, key) | ||
} | ||
slices.Sort(keys) | ||
return keys | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package collections | ||
|
||
import ( | ||
"cmp" | ||
"slices" | ||
) | ||
|
||
type OrderableSet[T cmp.Ordered] struct { | ||
m map[T]struct{} | ||
} | ||
|
||
func NewOrderableSet[T cmp.Ordered](values ...T) *OrderableSet[T] { | ||
newSet := &OrderableSet[T]{m: make(map[T]struct{})} | ||
for _, value := range values { | ||
newSet.Add(value) | ||
} | ||
return newSet | ||
} | ||
|
||
func (s *OrderableSet[T]) Add(value T) { | ||
s.m[value] = struct{}{} | ||
} | ||
|
||
func (s *OrderableSet[T]) Has(value T) bool { | ||
_, ok := s.m[value] | ||
return ok | ||
} | ||
|
||
func (s *OrderableSet[T]) Remove(value T) { | ||
delete(s.m, value) | ||
} | ||
|
||
func (s *OrderableSet[T]) Count() int { | ||
return len(s.m) | ||
} | ||
|
||
func (s *OrderableSet[T]) SortedValues() []T { | ||
values := make([]T, 0, len(s.m)) | ||
for value := range s.m { | ||
values = append(values, value) | ||
} | ||
slices.Sort(values) | ||
return values | ||
} |
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
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
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
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
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
Oops, something went wrong.