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

mlange-42 / arche / 4873167893

03 May 2023 02:36PM CUT coverage: 100.0%. Remained the same
4873167893

push

github

GitHub
Batch-exchange and add with target (#264)

163 of 163 new or added lines in 7 files covered. (100.0%)

3657 of 3657 relevant lines covered (100.0%)

100168.69 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,562✔
23
        return s.Archetype
100,562✔
24
}
100,562✔
25

26
// Len returns the current number of items in the paged array.
27
func (s singleArchetype) Len() int32 {
101,738✔
28
        return 1
101,738✔
29
}
101,738✔
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
        OldArchetype *archetype
39
        Added        []ID
40
        Removed      []ID
41
}
42

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

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

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

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

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

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

84
// Len returns the current number of items in the paged array.
85
func (a *archetypePointers) Len() int32 {
34✔
86
        return int32(len(a.pointers))
34✔
87
}
34✔
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