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

mlange-42 / arche / 12455637666

22 Dec 2024 03:48PM CUT coverage: 100.0%. Remained the same
12455637666

Pull #442

github

web-flow
Merge dcf4cea1c into 30c1f4bc4
Pull Request #442: Update CHANGELOG for release v0.14.0

6411 of 6411 relevant lines covered (100.0%)

114030.79 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 archetypes.
4
type archetypes interface {
5
        Get(index int32) *archetype
6
        Len() int32
7
}
8

9
// Implementation of an archetype iterator for a single archetype.
10
// Implements [archetypes].
11
type singleArchetype struct {
12
        Archetype *archetype
13
}
14

15
// Get returns the value at the given index.
16
func (s singleArchetype) Get(index int32) *archetype {
104,780✔
17
        return s.Archetype
104,780✔
18
}
104,780✔
19

20
// Len returns the current number of items in the paged array.
21
func (s singleArchetype) Len() int32 {
100,064✔
22
        return 1
100,064✔
23
}
100,064✔
24

25
// Implementation of an archetype iterator for a single archetype and partial iteration.
26
// Implements [archetypes].
27
//
28
// Used for the [Query] returned by entity batch creation methods.
29
type batchArchetypes struct {
30
        Archetype    []*archetype
31
        StartIndex   []uint32
32
        EndIndex     []uint32
33
        OldArchetype []*archetype
34
        Added        []ID
35
        Removed      []ID
36
}
37

38
// Get returns the value at the given index.
39
func (s *batchArchetypes) Get(index int32) *archetype {
80✔
40
        return s.Archetype[index]
80✔
41
}
80✔
42

43
// Len returns the current number of items in the paged array.
44
func (s *batchArchetypes) Len() int32 {
172✔
45
        return int32(len(s.Archetype))
172✔
46
}
172✔
47

48
func (s *batchArchetypes) Add(arch, oldArch *archetype, start, end uint32) {
83✔
49
        s.Archetype = append(s.Archetype, arch)
83✔
50
        s.OldArchetype = append(s.OldArchetype, oldArch)
83✔
51
        s.StartIndex = append(s.StartIndex, start)
83✔
52
        s.EndIndex = append(s.EndIndex, end)
83✔
53
}
83✔
54

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

63
// Get returns the value at the given index.
64
func (a *pointers[T]) Get(index int32) *T {
9✔
65
        return a.pointers[index]
9✔
66
}
9✔
67

68
// Add an element.
69
func (a *pointers[T]) Add(elem *T) {
32✔
70
        a.pointers = append(a.pointers, elem)
32✔
71
}
32✔
72

73
// RemoveAt swap-removes an element at a given index.
74
//
75
// Returns whether it was a swap.
76
func (a *pointers[T]) RemoveAt(index int) bool {
9✔
77
        ln := len(a.pointers)
9✔
78
        if index == ln-1 {
13✔
79
                a.pointers[index] = nil
4✔
80
                a.pointers = a.pointers[:index]
4✔
81
                return false
4✔
82
        }
4✔
83
        a.pointers[index], a.pointers[ln-1] = a.pointers[ln-1], nil
5✔
84
        a.pointers = a.pointers[:ln-1]
5✔
85
        return true
5✔
86
}
87

88
// Len returns the current number of items in the paged array.
89
func (a *pointers[T]) Len() int32 {
20✔
90
        return int32(len(a.pointers))
20✔
91
}
20✔
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