Index functions

This commit is contained in:
Simon Martens
2025-03-26 16:18:53 +01:00
parent dd24aea0a3
commit 052f21e87a
10 changed files with 240 additions and 23 deletions

View File

@@ -89,13 +89,13 @@ func (p *XMLParser[T]) Serialize(dataholder XMLRootElement[T], path string, late
// It deletes all items that have not been parsed in the last commit,
// and whose filepath has not been marked as failed.
func (p *XMLParser[T]) Cleanup(latest ParseMeta) {
todelete := make([]string, 0)
todelete := make([]any, 0)
toappend := make([]*T, 0)
p.Infos.Range(func(key, value interface{}) bool {
info := value.(ItemInfo)
if !info.Parse.Equals(latest) {
if !latest.Failed(info.Source) {
todelete = append(todelete, key.(string))
todelete = append(todelete, key)
} else {
item, ok := p.Items.Load(key)
if ok {
@@ -165,7 +165,7 @@ func (p *XMLParser[T]) Info(id string) ItemInfo {
return info.(ItemInfo)
}
func (p *XMLParser[T]) Item(id string) *T {
func (p *XMLParser[T]) Item(id any) *T {
item, ok := p.Items.Load(id)
if !ok {
return nil