Skip to content

Commit

Permalink
Added GetAllReferences() and GetAllMappedReferences() methods to Rolodex
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin Lobo committed Aug 19, 2024
1 parent 132b01e commit e3e9a67
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions index/rolodex.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"io/fs"
"log/slog"
"maps"
"math"
"os"
"path/filepath"
Expand Down Expand Up @@ -425,6 +426,26 @@ func (r *Rolodex) BuildIndexes() {
r.manualBuilt = true
}

// GetAllReferences returns all references found in the root and all other indices
func (r *Rolodex) GetAllReferences() map[string]*Reference {
allRefs := make(map[string]*Reference)
for _, idx := range append(r.GetIndexes(), r.GetRootIndex()) {
refs := idx.GetAllReferences()
maps.Copy(allRefs, refs)
}
return allRefs
}

// GetAllMappedReferences returns all mapped references found in the root and all other indices
func (r *Rolodex) GetAllMappedReferences() map[string]*Reference {
mappedRefs := make(map[string]*Reference)
for _, idx := range append(r.GetIndexes(), r.GetRootIndex()) {
refs := idx.GetMappedReferences()
maps.Copy(mappedRefs, refs)
}
return mappedRefs
}

// Open opens a file in the rolodex, and returns a RolodexFile.
func (r *Rolodex) Open(location string) (RolodexFile, error) {

Expand Down

0 comments on commit e3e9a67

Please sign in to comment.