-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite the package using Generics and add Module support
Signed-off-by: murad <mohammad.murad@mondu.ai>
- Loading branch information
murad
committed
Mar 26, 2023
1 parent
dbe832a
commit 3d1aafc
Showing
6 changed files
with
100 additions
and
145 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,37 @@ | ||
package ordered_sync_map_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
ordered_sync_map "github.com/m-murad/ordered-sync-map" | ||
) | ||
|
||
func ExampleNew() { | ||
|
||
mp := ordered_sync_map.New[string, string]() | ||
|
||
mp.Put("k1", "v1") | ||
|
||
v, ok := mp.Get("k1") | ||
fmt.Println(v, ok) | ||
|
||
ok = mp.Delete("k2") | ||
fmt.Println(ok) | ||
|
||
mp.UnorderedRange(func(key, value string) { | ||
fmt.Println(key, value) | ||
}) | ||
|
||
mp.OrderedRange(func(key, value string) { | ||
fmt.Println(key, value) | ||
}) | ||
|
||
len := mp.Length() | ||
fmt.Println(len) | ||
|
||
v, ok = mp.GetOrPut("k1", "v2") | ||
fmt.Println(v, ok) | ||
|
||
v, ok = mp.GetAndDelete("k1") | ||
fmt.Println(v, ok) | ||
} |
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,3 @@ | ||
module github.com/m-murad/ordered-sync-map | ||
|
||
go 1.20 |
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.