-
Notifications
You must be signed in to change notification settings - Fork 1
/
gong_slices.go
42 lines (38 loc) · 1.48 KB
/
gong_slices.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// generated code - do not edit
package x
// EvictInOtherSlices allows for adherance between
// the gong association model and go.
//
// Says you have a Astruct struct with a slice field "anarrayofb []*Bstruct"
//
// go allows many Astruct instance to have the anarrayofb field that have the
// same pointers. go slices are MANY-MANY association.
//
// With gong it is only ZERO-ONE-MANY associations, a Bstruct can be pointed only
// once by an Astruct instance through a given field. This follows the requirement
// that gong is suited for full stack programming and therefore the association
// is encoded as a reverse pointer (not as a joint table). In gong, a named struct
// is translated in a table and each table is a named struct.
//
// EvictInOtherSlices removes the fields instances from other
// fields of other instance
//
// Note : algo is in O(N)log(N) of nb of Astruct and Bstruct instances
func EvictInOtherSlices[OwningType PointerToGongstruct, FieldType PointerToGongstruct](
stage *StageStruct,
owningInstance OwningType,
sliceField []FieldType,
fieldName string) {
// create a map of the field elements
setOfFieldInstances := make(map[FieldType]any, 0)
for _, fieldInstance := range sliceField {
setOfFieldInstances[fieldInstance] = true
}
switch owningInstanceInfered := any(owningInstance).(type) {
// insertion point
case *A:
// insertion point per field
default:
_ = owningInstanceInfered // to avoid "declared and not used" error if no named struct has slices
}
}