forked from sionide21/Go2Lunch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vectors.go
29 lines (18 loc) · 834 Bytes
/
vectors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The vector package implements containers for managing sequences
// of elements. Vectors grow and shrink dynamically as necessary.
package main
type PersonVector []*Person
type PlaceVector []*Place
// Initial underlying array size
const initialSize = 8
// Partial sort.Interface support
// LessInterface provides partial support of the sort.Interface.
type LessInterface interface {
Less(y interface{}) bool
}
// Less returns a boolean denoting whether the i'th element is less than the j'th element.
func (p *PlaceVector) Less(i, j int) bool { return (*p)[i].Id < (*p)[j].Id }
func (p *PersonVector) Less(i, j int) bool { return (*p)[i].Name < (*p)[j].Name }