New common interface for PackgeCollection & PackageList: PackageCatalog. #80

This commit is contained in:
Andrey Smirnov
2014-08-28 19:41:30 +04:00
parent ed03a7c69e
commit 608870265c
3 changed files with 105 additions and 31 deletions
+18
View File
@@ -41,6 +41,7 @@ type PackageList struct {
// Verify interface
var (
_ sort.Interface = &PackageList{}
_ PackageCatalog = &PackageList{}
)
// NewPackageList creates empty package list
@@ -356,6 +357,23 @@ func (l *PackageList) Scan(q PackageQuery) (result *PackageList) {
return
}
// SearchSupported returns true for PackageList
func (l *PackageList) SearchSupported() bool {
return true
}
// SearchByKey looks up package by exact key reference
func (l *PackageList) SearchByKey(arch, name, version string) (result *PackageList) {
result = NewPackageList()
pkg := l.packages["P"+arch+" "+name+" "+version]
if pkg != nil {
result.Add(pkg)
}
return
}
// Search searches package index for specified package(s) using optimized queries
func (l *PackageList) Search(dep Dependency, allMatches bool) (searchResults []*Package) {
if !l.indexed {