• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / arche / 4874413404

03 May 2023 04:46PM CUT coverage: 100.0%. Remained the same
4874413404

push

github

GitHub
Batch-set entity relation, RelationFilter to function (#265)

137 of 137 new or added lines in 6 files covered. (100.0%)

3764 of 3764 relevant lines covered (100.0%)

97404.29 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/ecs/archetypes.go
1
package ecs
2

3
// Interface for an iterator over multiple archetypes.
4
type nodes interface {
5
        Get(index int32) *archetypeNode
6
        Len() int32
7
}
8

9
// Interface for an iterator over archetypes.
10
type archetypes interface {
11
        Get(index int32) *archetype
12
        Len() int32
13
}
14

15
// Implementation of an archetype iterator for a single archetype.
16
// Implements [archetypes].
17
type singleArchetype struct {
18
        Archetype *archetype
19
}
20

21
// Get returns the value at the given index.
22
func (s singleArchetype) Get(index int32) *archetype {
100,565✔
23
        return s.Archetype
100,565✔
24
}
100,565✔
25

26
// Len returns the current number of items in the paged array.
27
func (s singleArchetype) Len() int32 {
101,741✔
28
        return 1
101,741✔
29
}
101,741✔
30

31
// Implementation of an archetype iterator for a single archetype and partial iteration.
32
// Implements [archetypes].
33
//
34
// Used for the [Query] returned by entity batch creation methods.
35
type batchArchetype struct {
36
        Archetype    *archetype
37
        StartIndex   uint32
38
        EndIndex     uint32
39
        OldArchetype *archetype
40
        Added        []ID
41
        Removed      []ID
42
}
43

44
// Get returns the value at the given index.
45
func (s batchArchetype) Get(index int32) *archetype {
34✔
46
        return s.Archetype
34✔
47
}
34✔
48

49
// Len returns the current number of items in the paged array.
50
func (s batchArchetype) Len() int32 {
74✔
51
        return 1
74✔
52
}
74✔
53

54
// Implementation of an archetype iterator for pointers.
55
// Implements [archetypes].
56
//
57
// Used for tracking filter archetypes in [Cache].
58
type archetypePointers struct {
59
        pointers []*archetype
60
}
61

62
// Get returns the value at the given index.
63
func (a *archetypePointers) Get(index int32) *archetype {
82✔
64
        return a.pointers[index]
82✔
65
}
82✔
66

67
// Add an element.
68
func (a *archetypePointers) Add(arch *archetype) {
22✔
69
        a.pointers = append(a.pointers, arch)
22✔
70
}
22✔
71

72
// Remove an element.
73
func (a *archetypePointers) Remove(arch *archetype) {
2✔
74
        ln := len(a.pointers)
2✔
75
        for i := 0; i < ln; i++ {
5✔
76
                arch2 := a.pointers[i]
3✔
77
                if arch == arch2 {
5✔
78
                        a.pointers[i], a.pointers[ln-1] = a.pointers[ln-1], nil
2✔
79
                        a.pointers = a.pointers[:ln-1]
2✔
80
                        return
2✔
81
                }
2✔
82
        }
83
}
84

85
// Len returns the current number of items in the paged array.
86
func (a *archetypePointers) Len() int32 {
46✔
87
        return int32(len(a.pointers))
46✔
88
}
46✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc