point_vector.go (2029B)
1 // Copyright 2017 Google Inc. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package s2 16 17 // Shape interface enforcement 18 var ( 19 _ Shape = (*PointVector)(nil) 20 ) 21 22 // PointVector is a Shape representing a set of Points. Each point 23 // is represented as a degenerate edge with the same starting and ending 24 // vertices. 25 // 26 // This type is useful for adding a collection of points to an ShapeIndex. 27 // 28 // Its methods are on *PointVector due to implementation details of ShapeIndex. 29 type PointVector []Point 30 31 func (p *PointVector) NumEdges() int { return len(*p) } 32 func (p *PointVector) Edge(i int) Edge { return Edge{(*p)[i], (*p)[i]} } 33 func (p *PointVector) ReferencePoint() ReferencePoint { return OriginReferencePoint(false) } 34 func (p *PointVector) NumChains() int { return len(*p) } 35 func (p *PointVector) Chain(i int) Chain { return Chain{i, 1} } 36 func (p *PointVector) ChainEdge(i, j int) Edge { return Edge{(*p)[i], (*p)[j]} } 37 func (p *PointVector) ChainPosition(e int) ChainPosition { return ChainPosition{e, 0} } 38 func (p *PointVector) Dimension() int { return 0 } 39 func (p *PointVector) IsEmpty() bool { return defaultShapeIsEmpty(p) } 40 func (p *PointVector) IsFull() bool { return defaultShapeIsFull(p) } 41 func (p *PointVector) typeTag() typeTag { return typeTagPointVector } 42 func (p *PointVector) privateInterface() {}