-
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.
- Loading branch information
1 parent
7e77498
commit 7fb77b0
Showing
6 changed files
with
102 additions
and
47 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package acmelib | ||
|
||
type templateRef interface { | ||
EntityID() EntityID | ||
} | ||
|
||
type template[Ent any, Ref templateRef] struct { | ||
entity Ent | ||
refs *set[EntityID, Ref] | ||
} | ||
|
||
func newTemplate[Ent any, Ref templateRef](e Ent) *template[Ent, Ref] { | ||
return &template[Ent, Ref]{ | ||
entity: e, | ||
|
||
refs: newSet[EntityID, Ref](), | ||
} | ||
} | ||
|
||
func (t *template[Ent, Ref]) addRef(ref Ref) { | ||
t.refs.add(ref.EntityID(), ref) | ||
} | ||
|
||
func (t *template[Ent, Ref]) removeRef(refID EntityID) { | ||
t.refs.remove(refID) | ||
} |