package ii

type Items interface {
	Has(name Name) (*ItemInfo, bool)
	All() []*ItemInfo
}

type ItemIndex map[Name]*ItemInfo

func (idx ItemIndex) Has(name Name) (*ItemInfo, bool) {
	info, ok := idx[name]
	if !ok {
		return nil, false
	}
	return info, true
}

func (idx ItemIndex) All() []*ItemInfo {
	list := make([]*ItemInfo, 0, len(idx))
	for _, info := range idx {
		list = append(list, info)
	}
	return list
}
