2 Copyright 2015 The Kubernetes Authors.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
25 // Orderer produces an ordering of types given a Namer.
30 // OrderUniverse assigns a name to every type in the Universe, including Types,
31 // Functions and Variables, and returns a list sorted by those names.
32 func (o *Orderer) OrderUniverse(u types.Universe) []*types.Type {
37 for _, t := range p.Types {
38 list.types = append(list.types, t)
40 for _, f := range p.Functions {
41 list.types = append(list.types, f)
43 for _, v := range p.Variables {
44 list.types = append(list.types, v)
51 // OrderTypes assigns a name to every type, and returns a list sorted by those
53 func (o *Orderer) OrderTypes(typeList []*types.Type) []*types.Type {
67 func (t tList) Len() int { return len(t.types) }
68 func (t tList) Less(i, j int) bool { return t.namer.Name(t.types[i]) < t.namer.Name(t.types[j]) }
69 func (t tList) Swap(i, j int) { t.types[i], t.types[j] = t.types[j], t.types[i] }