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

mlange-42 / arche / 4854848992 / 1

Source File

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
//
18
// Used for the [Query] returned by entity batch creation methods.
19
type batchArchetype struct {
20
        Archetype  *archetype
21
        StartIndex uint32
22
}
23

24
// Get returns the value at the given index.
25
func (s batchArchetype) Get(index int32) *archetype {
482✔
26
        return s.Archetype
482✔
27
}
482✔
28

29
// Len returns the current number of items in the paged array.
30
func (s batchArchetype) Len() int32 {
1,664✔
31
        return 1
1,664✔
32
}
1,664✔
33

34
// Implementation of an archetype iterator for pointers.
35
// Implements [archetypes].
36
//
37
// Used for tracking filter archetypes in [Cache].
38
type archetypePointers struct {
39
        pointers []*archetype
40
}
41

42
// Get returns the value at the given index.
43
func (a *archetypePointers) Get(index int32) *archetype {
21✔
44
        return a.pointers[index]
21✔
45
}
21✔
46

47
// Add adds an element.
48
func (a *archetypePointers) Add(arch *archetype) {
52✔
49
        a.pointers = append(a.pointers, arch)
52✔
50
}
52✔
51

52
// Add adds an element.
53
func (a *archetypePointers) Remove(arch *archetype) {
2✔
54
        for i := 0; i < len(a.pointers); i++ {
5✔
55
                arch2 := a.pointers[i]
3✔
56
                if arch == arch2 {
5✔
57
                        a.pointers = append(a.pointers[:i], a.pointers[i+1:]...)
2✔
58
                        return
2✔
59
                }
2✔
60
        }
61
}
62

63
// Len returns the current number of items in the paged array.
64
func (a *archetypePointers) Len() int32 {
22✔
65
        return int32(len(a.pointers))
22✔
66
}
22✔
  • Back to Build 4854848992
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