diff options
Diffstat (limited to 'refs.sort.go')
| -rw-r--r-- | refs.sort.go | 41 |
1 files changed, 5 insertions, 36 deletions
diff --git a/refs.sort.go b/refs.sort.go index 8d8a9ea..94d3124 100644 --- a/refs.sort.go +++ b/refs.sort.go @@ -65,7 +65,7 @@ func (r *Refs) All() *RefIterator { func (r *Refs) SortByName() *RefIterator { packs := r.selectAllRefs() - sort.Sort(ByName(packs)) + sort.Sort(RefsByName(packs)) iterator := NewRefIterator(packs) return iterator @@ -113,11 +113,11 @@ func (r *Refs) Len() int { return len(r.Refs) } -type ByName []*Ref +type RefsByName []*Ref -func (a ByName) Len() int { return len(a) } -func (a ByName) Less(i, j int) bool { return a[i].RefName < a[j].RefName } -func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a RefsByName) Len() int { return len(a) } +func (a RefsByName) Less(i, j int) bool { return a[i].RefName < a[j].RefName } +func (a RefsByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } // safely returns a slice of pointers to the Ref protobufs func (r *Refs) selectAllRefs() []*Ref { @@ -147,34 +147,3 @@ func (all *Refs) DeleteByHash(hash string) *Ref { } return nil } - -/* -func (r *Refs) UnmergedRefRepos() *RefRepoIterator { - repoPointers := r.selectUnmergedRefRepos() - - sort.Sort(ByName(repoPointers)) - - iterator := NewRefRepoIterator(repoPointers) - - return iterator -} -*/ - -/* -// this sort doesn't really work. I think it forgets to sort the last two -// todo: sort this out. literally -// SelectRefPointers safely returns a slice of pointers to Ref records. -func (r *Refs) selectUnmergedRefs() []*RefRow { - r.RLock() - defer r.RUnlock() - - // Create a new slice to hold pointers to each Ref - // repoPointers := make([]*Ref, len(c.E.Refs)) - var repoPointers []*RefRow - for _, repo := range me.allrepos { - repoPointers = append(repoPointers, repo) // Copy pointers for safe iteration - } - - return repoPointers -} -*/ |
