-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: [generic + sort] All ready for generics #483
Merged
tjgurwara99
merged 10 commits into
TheAlgorithms:master
from
tjgurwara99:feature/generics-interfaces
Mar 26, 2022
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0b0d8a4
fix: [generic + sort] All ready for generics
tjgurwara99 d44aa9a
GoDocMD support for Go 1.18
tjgurwara99 a7ef6b8
Bump Go version in workflow
tjgurwara99 a8f6593
Updated Documentation in README.md
529ed6b
bump go version in GoLangCI lint action
tjgurwara99 356a106
fix: [generic + sort] review feedback
tjgurwara99 71e9258
Merge branch 'feature/generics-interfaces' of https://github.com/tjgu…
tjgurwara99 8c47508
Updated Documentation in README.md
77258e8
empty commit: stuck github action
tjgurwara99 3eccbd5
Merge branch 'feature/generics-interfaces' of https://github.com/tjgu…
tjgurwara99 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Package constraints has some useful generic type constraints defined which is very similar to | ||
// [golang.org/x/exp/constraints](https://pkg.go.dev/golang.org/x/exp/constraints) package. | ||
// We refrained from using that until it gets placed into the standard library - currently | ||
// there are some questions regarding this package [ref](https://github.com/golang/go/issues/50792). | ||
package constraints | ||
|
||
// Signed is a generic type constraint for all signed integers. | ||
type Signed interface { | ||
~int | ~int8 | ~int16 | ~int32 | ~int64 | ||
} | ||
|
||
// Unsigned is a generic type constraint for all unsigned integers. | ||
type Unsigned interface { | ||
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ||
} | ||
|
||
// Integer is a generic type constraint for all integers (signed and unsigned.) | ||
type Integer interface { | ||
Signed | Unsigned | ||
} | ||
|
||
// Float is a generic type constraint for all floating point types. | ||
type Float interface { | ||
~float32 | ~float64 | ||
} | ||
|
||
// Number is a generic type constraint for all numeric types in Go except Complex types. | ||
type Number interface { | ||
Integer | Float | ||
} | ||
|
||
// Ordered is a generic type constraint for all ordered data types in Go. | ||
// Loosely speaking, in mathematics a field is an ordered field if there is a "total | ||
// order" (a binary relation - in this case `<` symbol) such that we will always have | ||
// if a < b then a + c < b + c and if 0 < a, 0 < b then 0 < a.b | ||
// The idea in Go is quite similar, though only limited to Go standard types | ||
// not user defined types. | ||
type Ordered interface { | ||
Integer | ~string | Float | ||
} |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module github.com/TheAlgorithms/Go | ||
|
||
go 1.17 | ||
go 1.18 |
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't this
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Primarily because I missed it... Feel free to open a PR to rectify it.