id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,200 | golang/geo | s2/shapeindex.go | addFaceEdge | func (s *ShapeIndex) addFaceEdge(fe faceEdge, allEdges [][]faceEdge) {
aFace := face(fe.edge.V0.Vector)
// See if both endpoints are on the same face, and are far enough from
// the edge of the face that they don't intersect any (padded) adjacent face.
if aFace == face(fe.edge.V1.Vector) {
x, y := validFaceXYZToU... | go | func (s *ShapeIndex) addFaceEdge(fe faceEdge, allEdges [][]faceEdge) {
aFace := face(fe.edge.V0.Vector)
// See if both endpoints are on the same face, and are far enough from
// the edge of the face that they don't intersect any (padded) adjacent face.
if aFace == face(fe.edge.V1.Vector) {
x, y := validFaceXYZToU... | [
"func",
"(",
"s",
"*",
"ShapeIndex",
")",
"addFaceEdge",
"(",
"fe",
"faceEdge",
",",
"allEdges",
"[",
"]",
"[",
"]",
"faceEdge",
")",
"{",
"aFace",
":=",
"face",
"(",
"fe",
".",
"edge",
".",
"V0",
".",
"Vector",
")",
"\n",
"// See if both endpoints are... | // addFaceEdge adds the given faceEdge into the collection of all edges. | [
"addFaceEdge",
"adds",
"the",
"given",
"faceEdge",
"into",
"the",
"collection",
"of",
"all",
"edges",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L871-L898 |
28,201 | golang/geo | s2/shapeindex.go | shrinkToFit | func (s *ShapeIndex) shrinkToFit(pcell *PaddedCell, bound r2.Rect) CellID {
shrunkID := pcell.ShrinkToFit(bound)
if !s.isFirstUpdate() && shrunkID != pcell.CellID() {
// Don't shrink any smaller than the existing index cells, since we need
// to combine the new edges with those cells.
iter := s.Iterator()
if... | go | func (s *ShapeIndex) shrinkToFit(pcell *PaddedCell, bound r2.Rect) CellID {
shrunkID := pcell.ShrinkToFit(bound)
if !s.isFirstUpdate() && shrunkID != pcell.CellID() {
// Don't shrink any smaller than the existing index cells, since we need
// to combine the new edges with those cells.
iter := s.Iterator()
if... | [
"func",
"(",
"s",
"*",
"ShapeIndex",
")",
"shrinkToFit",
"(",
"pcell",
"*",
"PaddedCell",
",",
"bound",
"r2",
".",
"Rect",
")",
"CellID",
"{",
"shrunkID",
":=",
"pcell",
".",
"ShrinkToFit",
"(",
"bound",
")",
"\n\n",
"if",
"!",
"s",
".",
"isFirstUpdate... | // shrinkToFit shrinks the PaddedCell to fit within the given bounds. | [
"shrinkToFit",
"shrinks",
"the",
"PaddedCell",
"to",
"fit",
"within",
"the",
"given",
"bounds",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L950-L962 |
28,202 | golang/geo | s2/shapeindex.go | skipCellRange | func (s *ShapeIndex) skipCellRange(begin, end CellID, t *tracker, disjointFromIndex bool) {
// If we aren't in the interior of a shape, then skipping over cells is easy.
if len(t.shapeIDs) == 0 {
return
}
// Otherwise generate the list of cell ids that we need to visit, and create
// an index entry for each one... | go | func (s *ShapeIndex) skipCellRange(begin, end CellID, t *tracker, disjointFromIndex bool) {
// If we aren't in the interior of a shape, then skipping over cells is easy.
if len(t.shapeIDs) == 0 {
return
}
// Otherwise generate the list of cell ids that we need to visit, and create
// an index entry for each one... | [
"func",
"(",
"s",
"*",
"ShapeIndex",
")",
"skipCellRange",
"(",
"begin",
",",
"end",
"CellID",
",",
"t",
"*",
"tracker",
",",
"disjointFromIndex",
"bool",
")",
"{",
"// If we aren't in the interior of a shape, then skipping over cells is easy.",
"if",
"len",
"(",
"t... | // skipCellRange skips over the cells in the given range, creating index cells if we are
// currently in the interior of at least one shape. | [
"skipCellRange",
"skips",
"over",
"the",
"cells",
"in",
"the",
"given",
"range",
"creating",
"index",
"cells",
"if",
"we",
"are",
"currently",
"in",
"the",
"interior",
"of",
"at",
"least",
"one",
"shape",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L966-L979 |
28,203 | golang/geo | s2/shapeindex.go | makeIndexCell | func (s *ShapeIndex) makeIndexCell(p *PaddedCell, edges []*clippedEdge, t *tracker) bool {
// If the cell is empty, no index cell is needed. (In most cases this
// situation is detected before we get to this point, but this can happen
// when all shapes in a cell are removed.)
if len(edges) == 0 && len(t.shapeIDs) ... | go | func (s *ShapeIndex) makeIndexCell(p *PaddedCell, edges []*clippedEdge, t *tracker) bool {
// If the cell is empty, no index cell is needed. (In most cases this
// situation is detected before we get to this point, but this can happen
// when all shapes in a cell are removed.)
if len(edges) == 0 && len(t.shapeIDs) ... | [
"func",
"(",
"s",
"*",
"ShapeIndex",
")",
"makeIndexCell",
"(",
"p",
"*",
"PaddedCell",
",",
"edges",
"[",
"]",
"*",
"clippedEdge",
",",
"t",
"*",
"tracker",
")",
"bool",
"{",
"// If the cell is empty, no index cell is needed. (In most cases this",
"// situation is ... | // makeIndexCell builds an indexCell from the given padded cell and set of edges and adds
// it to the index. If the cell or edges are empty, no cell is added. | [
"makeIndexCell",
"builds",
"an",
"indexCell",
"from",
"the",
"given",
"padded",
"cell",
"and",
"set",
"of",
"edges",
"and",
"adds",
"it",
"to",
"the",
"index",
".",
"If",
"the",
"cell",
"or",
"edges",
"are",
"empty",
"no",
"cell",
"is",
"added",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L1121-L1233 |
28,204 | golang/geo | s2/shapeindex.go | updateBound | func (s *ShapeIndex) updateBound(edge *clippedEdge, uEnd int, u float64, vEnd int, v float64) *clippedEdge {
c := &clippedEdge{faceEdge: edge.faceEdge}
if uEnd == 0 {
c.bound.X.Lo = u
c.bound.X.Hi = edge.bound.X.Hi
} else {
c.bound.X.Lo = edge.bound.X.Lo
c.bound.X.Hi = u
}
if vEnd == 0 {
c.bound.Y.Lo = ... | go | func (s *ShapeIndex) updateBound(edge *clippedEdge, uEnd int, u float64, vEnd int, v float64) *clippedEdge {
c := &clippedEdge{faceEdge: edge.faceEdge}
if uEnd == 0 {
c.bound.X.Lo = u
c.bound.X.Hi = edge.bound.X.Hi
} else {
c.bound.X.Lo = edge.bound.X.Lo
c.bound.X.Hi = u
}
if vEnd == 0 {
c.bound.Y.Lo = ... | [
"func",
"(",
"s",
"*",
"ShapeIndex",
")",
"updateBound",
"(",
"edge",
"*",
"clippedEdge",
",",
"uEnd",
"int",
",",
"u",
"float64",
",",
"vEnd",
"int",
",",
"v",
"float64",
")",
"*",
"clippedEdge",
"{",
"c",
":=",
"&",
"clippedEdge",
"{",
"faceEdge",
... | // updateBound updates the specified endpoint of the given clipped edge and returns the
// resulting clipped edge. | [
"updateBound",
"updates",
"the",
"specified",
"endpoint",
"of",
"the",
"given",
"clipped",
"edge",
"and",
"returns",
"the",
"resulting",
"clipped",
"edge",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L1237-L1256 |
28,205 | golang/geo | s2/shapeindex.go | clipVAxis | func (s *ShapeIndex) clipVAxis(edge *clippedEdge, middle r1.Interval) (a, b *clippedEdge) {
if edge.bound.Y.Hi <= middle.Lo {
// Edge is entirely contained in the lower child.
return edge, nil
} else if edge.bound.Y.Lo >= middle.Hi {
// Edge is entirely contained in the upper child.
return nil, edge
}
// Th... | go | func (s *ShapeIndex) clipVAxis(edge *clippedEdge, middle r1.Interval) (a, b *clippedEdge) {
if edge.bound.Y.Hi <= middle.Lo {
// Edge is entirely contained in the lower child.
return edge, nil
} else if edge.bound.Y.Lo >= middle.Hi {
// Edge is entirely contained in the upper child.
return nil, edge
}
// Th... | [
"func",
"(",
"s",
"*",
"ShapeIndex",
")",
"clipVAxis",
"(",
"edge",
"*",
"clippedEdge",
",",
"middle",
"r1",
".",
"Interval",
")",
"(",
"a",
",",
"b",
"*",
"clippedEdge",
")",
"{",
"if",
"edge",
".",
"bound",
".",
"Y",
".",
"Hi",
"<=",
"middle",
... | // cliupVAxis returns the given edge clipped to within the boundaries of the middle
// interval along the v-axis, and adds the result to its children. | [
"cliupVAxis",
"returns",
"the",
"given",
"edge",
"clipped",
"to",
"within",
"the",
"boundaries",
"of",
"the",
"middle",
"interval",
"along",
"the",
"v",
"-",
"axis",
"and",
"adds",
"the",
"result",
"to",
"its",
"children",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L1326-L1336 |
28,206 | golang/geo | s2/shapeindex.go | countShapes | func (s *ShapeIndex) countShapes(edges []*clippedEdge, shapeIDs []int32) int {
count := 0
lastShapeID := int32(-1)
// next clipped shape id in the shapeIDs list.
clippedNext := int32(0)
// index of the current element in the shapeIDs list.
shapeIDidx := 0
for _, edge := range edges {
if edge.faceEdge.shapeID ... | go | func (s *ShapeIndex) countShapes(edges []*clippedEdge, shapeIDs []int32) int {
count := 0
lastShapeID := int32(-1)
// next clipped shape id in the shapeIDs list.
clippedNext := int32(0)
// index of the current element in the shapeIDs list.
shapeIDidx := 0
for _, edge := range edges {
if edge.faceEdge.shapeID ... | [
"func",
"(",
"s",
"*",
"ShapeIndex",
")",
"countShapes",
"(",
"edges",
"[",
"]",
"*",
"clippedEdge",
",",
"shapeIDs",
"[",
"]",
"int32",
")",
"int",
"{",
"count",
":=",
"0",
"\n",
"lastShapeID",
":=",
"int32",
"(",
"-",
"1",
")",
"\n\n",
"// next cli... | // countShapes reports the number of distinct shapes that are either associated with the
// given edges, or that are currently stored in the InteriorTracker. | [
"countShapes",
"reports",
"the",
"number",
"of",
"distinct",
"shapes",
"that",
"are",
"either",
"associated",
"with",
"the",
"given",
"edges",
"or",
"that",
"are",
"currently",
"stored",
"in",
"the",
"InteriorTracker",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L1468-L1500 |
28,207 | golang/geo | s2/shapeindex.go | maxLevelForEdge | func maxLevelForEdge(edge Edge) int {
// Compute the maximum cell size for which this edge is considered long.
// The calculation does not need to be perfectly accurate, so we use Norm
// rather than Angle for speed.
cellSize := edge.V0.Sub(edge.V1.Vector).Norm() * cellSizeToLongEdgeRatio
// Now return the first l... | go | func maxLevelForEdge(edge Edge) int {
// Compute the maximum cell size for which this edge is considered long.
// The calculation does not need to be perfectly accurate, so we use Norm
// rather than Angle for speed.
cellSize := edge.V0.Sub(edge.V1.Vector).Norm() * cellSizeToLongEdgeRatio
// Now return the first l... | [
"func",
"maxLevelForEdge",
"(",
"edge",
"Edge",
")",
"int",
"{",
"// Compute the maximum cell size for which this edge is considered long.",
"// The calculation does not need to be perfectly accurate, so we use Norm",
"// rather than Angle for speed.",
"cellSize",
":=",
"edge",
".",
"V... | // maxLevelForEdge reports the maximum level for a given edge. | [
"maxLevelForEdge",
"reports",
"the",
"maximum",
"level",
"for",
"a",
"given",
"edge",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeindex.go#L1503-L1511 |
28,208 | golang/geo | s2/edge_crosser.go | NewEdgeCrosser | func NewEdgeCrosser(a, b Point) *EdgeCrosser {
norm := a.PointCross(b)
return &EdgeCrosser{
a: a,
b: b,
aXb: Point{a.Cross(b.Vector)},
aTangent: Point{a.Cross(norm.Vector)},
bTangent: Point{norm.Cross(b.Vector)},
}
} | go | func NewEdgeCrosser(a, b Point) *EdgeCrosser {
norm := a.PointCross(b)
return &EdgeCrosser{
a: a,
b: b,
aXb: Point{a.Cross(b.Vector)},
aTangent: Point{a.Cross(norm.Vector)},
bTangent: Point{norm.Cross(b.Vector)},
}
} | [
"func",
"NewEdgeCrosser",
"(",
"a",
",",
"b",
"Point",
")",
"*",
"EdgeCrosser",
"{",
"norm",
":=",
"a",
".",
"PointCross",
"(",
"b",
")",
"\n",
"return",
"&",
"EdgeCrosser",
"{",
"a",
":",
"a",
",",
"b",
":",
"b",
",",
"aXb",
":",
"Point",
"{",
... | // NewEdgeCrosser returns an EdgeCrosser with the fixed edge AB. | [
"NewEdgeCrosser",
"returns",
"an",
"EdgeCrosser",
"with",
"the",
"fixed",
"edge",
"AB",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_crosser.go#L56-L65 |
28,209 | golang/geo | s2/edge_crosser.go | RestartAt | func (e *EdgeCrosser) RestartAt(c Point) {
e.c = c
e.acb = -triageSign(e.a, e.b, e.c)
} | go | func (e *EdgeCrosser) RestartAt(c Point) {
e.c = c
e.acb = -triageSign(e.a, e.b, e.c)
} | [
"func",
"(",
"e",
"*",
"EdgeCrosser",
")",
"RestartAt",
"(",
"c",
"Point",
")",
"{",
"e",
".",
"c",
"=",
"c",
"\n",
"e",
".",
"acb",
"=",
"-",
"triageSign",
"(",
"e",
".",
"a",
",",
"e",
".",
"b",
",",
"e",
".",
"c",
")",
"\n",
"}"
] | // RestartAt sets the current point of the edge crosser to be c.
// Call this method when your chain 'jumps' to a new place.
// The argument must point to a value that persists until the next call. | [
"RestartAt",
"sets",
"the",
"current",
"point",
"of",
"the",
"edge",
"crosser",
"to",
"be",
"c",
".",
"Call",
"this",
"method",
"when",
"your",
"chain",
"jumps",
"to",
"a",
"new",
"place",
".",
"The",
"argument",
"must",
"point",
"to",
"a",
"value",
"t... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_crosser.go#L120-L123 |
28,210 | golang/geo | s2/edge_crosser.go | crossingSign | func (e *EdgeCrosser) crossingSign(d Point, bda Direction) Crossing {
// Compute the actual result, and then save the current vertex D as the next
// vertex C, and save the orientation of the next triangle ACB (which is
// opposite to the current triangle BDA).
defer func() {
e.c = d
e.acb = -bda
}()
// At t... | go | func (e *EdgeCrosser) crossingSign(d Point, bda Direction) Crossing {
// Compute the actual result, and then save the current vertex D as the next
// vertex C, and save the orientation of the next triangle ACB (which is
// opposite to the current triangle BDA).
defer func() {
e.c = d
e.acb = -bda
}()
// At t... | [
"func",
"(",
"e",
"*",
"EdgeCrosser",
")",
"crossingSign",
"(",
"d",
"Point",
",",
"bda",
"Direction",
")",
"Crossing",
"{",
"// Compute the actual result, and then save the current vertex D as the next",
"// vertex C, and save the orientation of the next triangle ACB (which is",
... | // crossingSign handle the slow path of CrossingSign. | [
"crossingSign",
"handle",
"the",
"slow",
"path",
"of",
"CrossingSign",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_crosser.go#L163-L227 |
28,211 | golang/geo | s2/interleave.go | deinterleaveUint32 | func deinterleaveUint32(code uint64) (uint32, uint32) {
x := (deinterleaveLookup[code&0x55]) |
(deinterleaveLookup[(code>>8)&0x55] << 4) |
(deinterleaveLookup[(code>>16)&0x55] << 8) |
(deinterleaveLookup[(code>>24)&0x55] << 12) |
(deinterleaveLookup[(code>>32)&0x55] << 16) |
(deinterleaveLookup[(code>>40)&0x... | go | func deinterleaveUint32(code uint64) (uint32, uint32) {
x := (deinterleaveLookup[code&0x55]) |
(deinterleaveLookup[(code>>8)&0x55] << 4) |
(deinterleaveLookup[(code>>16)&0x55] << 8) |
(deinterleaveLookup[(code>>24)&0x55] << 12) |
(deinterleaveLookup[(code>>32)&0x55] << 16) |
(deinterleaveLookup[(code>>40)&0x... | [
"func",
"deinterleaveUint32",
"(",
"code",
"uint64",
")",
"(",
"uint32",
",",
"uint32",
")",
"{",
"x",
":=",
"(",
"deinterleaveLookup",
"[",
"code",
"&",
"0x55",
"]",
")",
"|",
"(",
"deinterleaveLookup",
"[",
"(",
"code",
">>",
"8",
")",
"&",
"0x55",
... | // deinterleaveUint32 decodes the interleaved values. | [
"deinterleaveUint32",
"decodes",
"the",
"interleaved",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/interleave.go#L71-L89 |
28,212 | golang/geo | s2/interleave.go | interleaveUint32 | func interleaveUint32(x, y uint32) uint64 {
return (interleaveLookup[x&0xff]) |
(interleaveLookup[(x>>8)&0xff] << 16) |
(interleaveLookup[(x>>16)&0xff] << 32) |
(interleaveLookup[x>>24] << 48) |
(interleaveLookup[y&0xff] << 1) |
(interleaveLookup[(y>>8)&0xff] << 17) |
(interleaveLookup[(y>>16)&0xff] << 33)... | go | func interleaveUint32(x, y uint32) uint64 {
return (interleaveLookup[x&0xff]) |
(interleaveLookup[(x>>8)&0xff] << 16) |
(interleaveLookup[(x>>16)&0xff] << 32) |
(interleaveLookup[x>>24] << 48) |
(interleaveLookup[y&0xff] << 1) |
(interleaveLookup[(y>>8)&0xff] << 17) |
(interleaveLookup[(y>>16)&0xff] << 33)... | [
"func",
"interleaveUint32",
"(",
"x",
",",
"y",
"uint32",
")",
"uint64",
"{",
"return",
"(",
"interleaveLookup",
"[",
"x",
"&",
"0xff",
"]",
")",
"|",
"(",
"interleaveLookup",
"[",
"(",
"x",
">>",
"8",
")",
"&",
"0xff",
"]",
"<<",
"16",
")",
"|",
... | // interleaveUint32 interleaves the given arguments into the return value.
//
// The 0-bit in val0 will be the 0-bit in the return value.
// The 0-bit in val1 will be the 1-bit in the return value.
// The 1-bit of val0 will be the 2-bit in the return value, and so on. | [
"interleaveUint32",
"interleaves",
"the",
"given",
"arguments",
"into",
"the",
"return",
"value",
".",
"The",
"0",
"-",
"bit",
"in",
"val0",
"will",
"be",
"the",
"0",
"-",
"bit",
"in",
"the",
"return",
"value",
".",
"The",
"0",
"-",
"bit",
"in",
"val1"... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/interleave.go#L134-L143 |
28,213 | golang/geo | s2/paddedcell.go | PaddedCellFromCellID | func PaddedCellFromCellID(id CellID, padding float64) *PaddedCell {
p := &PaddedCell{
id: id,
padding: padding,
middle: r2.EmptyRect(),
}
// Fast path for constructing a top-level face (the most common case).
if id.isFace() {
limit := padding + 1
p.bound = r2.Rect{r1.Interval{-limit, limit}, r1.Int... | go | func PaddedCellFromCellID(id CellID, padding float64) *PaddedCell {
p := &PaddedCell{
id: id,
padding: padding,
middle: r2.EmptyRect(),
}
// Fast path for constructing a top-level face (the most common case).
if id.isFace() {
limit := padding + 1
p.bound = r2.Rect{r1.Interval{-limit, limit}, r1.Int... | [
"func",
"PaddedCellFromCellID",
"(",
"id",
"CellID",
",",
"padding",
"float64",
")",
"*",
"PaddedCell",
"{",
"p",
":=",
"&",
"PaddedCell",
"{",
"id",
":",
"id",
",",
"padding",
":",
"padding",
",",
"middle",
":",
"r2",
".",
"EmptyRect",
"(",
")",
",",
... | // PaddedCellFromCellID constructs a padded cell with the given padding. | [
"PaddedCellFromCellID",
"constructs",
"a",
"padded",
"cell",
"with",
"the",
"given",
"padding",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/paddedcell.go#L37-L61 |
28,214 | golang/geo | s2/paddedcell.go | Center | func (p PaddedCell) Center() Point {
ijSize := sizeIJ(p.level)
si := uint32(2*p.iLo + ijSize)
ti := uint32(2*p.jLo + ijSize)
return Point{faceSiTiToXYZ(p.id.Face(), si, ti).Normalize()}
} | go | func (p PaddedCell) Center() Point {
ijSize := sizeIJ(p.level)
si := uint32(2*p.iLo + ijSize)
ti := uint32(2*p.jLo + ijSize)
return Point{faceSiTiToXYZ(p.id.Face(), si, ti).Normalize()}
} | [
"func",
"(",
"p",
"PaddedCell",
")",
"Center",
"(",
")",
"Point",
"{",
"ijSize",
":=",
"sizeIJ",
"(",
"p",
".",
"level",
")",
"\n",
"si",
":=",
"uint32",
"(",
"2",
"*",
"p",
".",
"iLo",
"+",
"ijSize",
")",
"\n",
"ti",
":=",
"uint32",
"(",
"2",
... | // Center returns the center of this cell. | [
"Center",
"returns",
"the",
"center",
"of",
"this",
"cell",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/paddedcell.go#L117-L122 |
28,215 | golang/geo | s2/paddedcell.go | EntryVertex | func (p PaddedCell) EntryVertex() Point {
// The curve enters at the (0,0) vertex unless the axis directions are
// reversed, in which case it enters at the (1,1) vertex.
i := p.iLo
j := p.jLo
if p.orientation&invertMask != 0 {
ijSize := sizeIJ(p.level)
i += ijSize
j += ijSize
}
return Point{faceSiTiToXYZ(... | go | func (p PaddedCell) EntryVertex() Point {
// The curve enters at the (0,0) vertex unless the axis directions are
// reversed, in which case it enters at the (1,1) vertex.
i := p.iLo
j := p.jLo
if p.orientation&invertMask != 0 {
ijSize := sizeIJ(p.level)
i += ijSize
j += ijSize
}
return Point{faceSiTiToXYZ(... | [
"func",
"(",
"p",
"PaddedCell",
")",
"EntryVertex",
"(",
")",
"Point",
"{",
"// The curve enters at the (0,0) vertex unless the axis directions are",
"// reversed, in which case it enters at the (1,1) vertex.",
"i",
":=",
"p",
".",
"iLo",
"\n",
"j",
":=",
"p",
".",
"jLo",... | // EntryVertex return the vertex where the space-filling curve enters this cell. | [
"EntryVertex",
"return",
"the",
"vertex",
"where",
"the",
"space",
"-",
"filling",
"curve",
"enters",
"this",
"cell",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/paddedcell.go#L155-L166 |
28,216 | golang/geo | s2/paddedcell.go | ShrinkToFit | func (p *PaddedCell) ShrinkToFit(rect r2.Rect) CellID {
// Quick rejection test: if rect contains the center of this cell along
// either axis, then no further shrinking is possible.
if p.level == 0 {
// Fast path (most calls to this function start with a face cell).
if rect.X.Contains(0) || rect.Y.Contains(0) {... | go | func (p *PaddedCell) ShrinkToFit(rect r2.Rect) CellID {
// Quick rejection test: if rect contains the center of this cell along
// either axis, then no further shrinking is possible.
if p.level == 0 {
// Fast path (most calls to this function start with a face cell).
if rect.X.Contains(0) || rect.Y.Contains(0) {... | [
"func",
"(",
"p",
"*",
"PaddedCell",
")",
"ShrinkToFit",
"(",
"rect",
"r2",
".",
"Rect",
")",
"CellID",
"{",
"// Quick rejection test: if rect contains the center of this cell along",
"// either axis, then no further shrinking is possible.",
"if",
"p",
".",
"level",
"==",
... | // ShrinkToFit returns the smallest CellID that contains all descendants of this
// padded cell whose bounds intersect the given rect. For algorithms that use
// recursive subdivision to find the cells that intersect a particular object, this
// method can be used to skip all of the initial subdivision steps where only... | [
"ShrinkToFit",
"returns",
"the",
"smallest",
"CellID",
"that",
"contains",
"all",
"descendants",
"of",
"this",
"padded",
"cell",
"whose",
"bounds",
"intersect",
"the",
"given",
"rect",
".",
"For",
"algorithms",
"that",
"use",
"recursive",
"subdivision",
"to",
"f... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/paddedcell.go#L195-L252 |
28,217 | golang/geo | r3/precisevector.go | precStr | func precStr(s string) *big.Float {
// Explicitly ignoring the bool return for this usage.
f, _ := new(big.Float).SetPrec(prec).SetString(s)
return f
} | go | func precStr(s string) *big.Float {
// Explicitly ignoring the bool return for this usage.
f, _ := new(big.Float).SetPrec(prec).SetString(s)
return f
} | [
"func",
"precStr",
"(",
"s",
"string",
")",
"*",
"big",
".",
"Float",
"{",
"// Explicitly ignoring the bool return for this usage.",
"f",
",",
"_",
":=",
"new",
"(",
"big",
".",
"Float",
")",
".",
"SetPrec",
"(",
"prec",
")",
".",
"SetString",
"(",
"s",
... | // precStr wraps the conversion from a string into a big.Float. For results that
// actually can be represented exactly, this should only be used on values that
// are integer multiples of integer powers of 2. | [
"precStr",
"wraps",
"the",
"conversion",
"from",
"a",
"string",
"into",
"a",
"big",
".",
"Float",
".",
"For",
"results",
"that",
"actually",
"can",
"be",
"represented",
"exactly",
"this",
"should",
"only",
"be",
"used",
"on",
"values",
"that",
"are",
"inte... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L38-L42 |
28,218 | golang/geo | r3/precisevector.go | PreciseVectorFromVector | func PreciseVectorFromVector(v Vector) PreciseVector {
return NewPreciseVector(v.X, v.Y, v.Z)
} | go | func PreciseVectorFromVector(v Vector) PreciseVector {
return NewPreciseVector(v.X, v.Y, v.Z)
} | [
"func",
"PreciseVectorFromVector",
"(",
"v",
"Vector",
")",
"PreciseVector",
"{",
"return",
"NewPreciseVector",
"(",
"v",
".",
"X",
",",
"v",
".",
"Y",
",",
"v",
".",
"Z",
")",
"\n",
"}"
] | // PreciseVectorFromVector creates a high precision vector from the given Vector. | [
"PreciseVectorFromVector",
"creates",
"a",
"high",
"precision",
"vector",
"from",
"the",
"given",
"Vector",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L74-L76 |
28,219 | golang/geo | r3/precisevector.go | NewPreciseVector | func NewPreciseVector(x, y, z float64) PreciseVector {
return PreciseVector{
X: precFloat(x),
Y: precFloat(y),
Z: precFloat(z),
}
} | go | func NewPreciseVector(x, y, z float64) PreciseVector {
return PreciseVector{
X: precFloat(x),
Y: precFloat(y),
Z: precFloat(z),
}
} | [
"func",
"NewPreciseVector",
"(",
"x",
",",
"y",
",",
"z",
"float64",
")",
"PreciseVector",
"{",
"return",
"PreciseVector",
"{",
"X",
":",
"precFloat",
"(",
"x",
")",
",",
"Y",
":",
"precFloat",
"(",
"y",
")",
",",
"Z",
":",
"precFloat",
"(",
"z",
"... | // NewPreciseVector creates a high precision vector from the given floating point values. | [
"NewPreciseVector",
"creates",
"a",
"high",
"precision",
"vector",
"from",
"the",
"given",
"floating",
"point",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L79-L85 |
28,220 | golang/geo | r3/precisevector.go | Vector | func (v PreciseVector) Vector() Vector {
// The accuracy flag is ignored on these conversions back to float64.
x, _ := v.X.Float64()
y, _ := v.Y.Float64()
z, _ := v.Z.Float64()
return Vector{x, y, z}.Normalize()
} | go | func (v PreciseVector) Vector() Vector {
// The accuracy flag is ignored on these conversions back to float64.
x, _ := v.X.Float64()
y, _ := v.Y.Float64()
z, _ := v.Z.Float64()
return Vector{x, y, z}.Normalize()
} | [
"func",
"(",
"v",
"PreciseVector",
")",
"Vector",
"(",
")",
"Vector",
"{",
"// The accuracy flag is ignored on these conversions back to float64.",
"x",
",",
"_",
":=",
"v",
".",
"X",
".",
"Float64",
"(",
")",
"\n",
"y",
",",
"_",
":=",
"v",
".",
"Y",
".",... | // Vector returns this precise vector converted to a Vector. | [
"Vector",
"returns",
"this",
"precise",
"vector",
"converted",
"to",
"a",
"Vector",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L88-L94 |
28,221 | golang/geo | r3/precisevector.go | Equal | func (v PreciseVector) Equal(ov PreciseVector) bool {
return v.X.Cmp(ov.X) == 0 && v.Y.Cmp(ov.Y) == 0 && v.Z.Cmp(ov.Z) == 0
} | go | func (v PreciseVector) Equal(ov PreciseVector) bool {
return v.X.Cmp(ov.X) == 0 && v.Y.Cmp(ov.Y) == 0 && v.Z.Cmp(ov.Z) == 0
} | [
"func",
"(",
"v",
"PreciseVector",
")",
"Equal",
"(",
"ov",
"PreciseVector",
")",
"bool",
"{",
"return",
"v",
".",
"X",
".",
"Cmp",
"(",
"ov",
".",
"X",
")",
"==",
"0",
"&&",
"v",
".",
"Y",
".",
"Cmp",
"(",
"ov",
".",
"Y",
")",
"==",
"0",
"... | // Equal reports whether v and ov are equal. | [
"Equal",
"reports",
"whether",
"v",
"and",
"ov",
"are",
"equal",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L97-L99 |
28,222 | golang/geo | r3/precisevector.go | Abs | func (v PreciseVector) Abs() PreciseVector {
return PreciseVector{
X: new(big.Float).Abs(v.X),
Y: new(big.Float).Abs(v.Y),
Z: new(big.Float).Abs(v.Z),
}
} | go | func (v PreciseVector) Abs() PreciseVector {
return PreciseVector{
X: new(big.Float).Abs(v.X),
Y: new(big.Float).Abs(v.Y),
Z: new(big.Float).Abs(v.Z),
}
} | [
"func",
"(",
"v",
"PreciseVector",
")",
"Abs",
"(",
")",
"PreciseVector",
"{",
"return",
"PreciseVector",
"{",
"X",
":",
"new",
"(",
"big",
".",
"Float",
")",
".",
"Abs",
"(",
"v",
".",
"X",
")",
",",
"Y",
":",
"new",
"(",
"big",
".",
"Float",
... | // Abs returns the vector with nonnegative components. | [
"Abs",
"returns",
"the",
"vector",
"with",
"nonnegative",
"components",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L114-L120 |
28,223 | golang/geo | r3/precisevector.go | Add | func (v PreciseVector) Add(ov PreciseVector) PreciseVector {
return PreciseVector{
X: precAdd(v.X, ov.X),
Y: precAdd(v.Y, ov.Y),
Z: precAdd(v.Z, ov.Z),
}
} | go | func (v PreciseVector) Add(ov PreciseVector) PreciseVector {
return PreciseVector{
X: precAdd(v.X, ov.X),
Y: precAdd(v.Y, ov.Y),
Z: precAdd(v.Z, ov.Z),
}
} | [
"func",
"(",
"v",
"PreciseVector",
")",
"Add",
"(",
"ov",
"PreciseVector",
")",
"PreciseVector",
"{",
"return",
"PreciseVector",
"{",
"X",
":",
"precAdd",
"(",
"v",
".",
"X",
",",
"ov",
".",
"X",
")",
",",
"Y",
":",
"precAdd",
"(",
"v",
".",
"Y",
... | // Add returns the standard vector sum of v and ov. | [
"Add",
"returns",
"the",
"standard",
"vector",
"sum",
"of",
"v",
"and",
"ov",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L123-L129 |
28,224 | golang/geo | r3/precisevector.go | Sub | func (v PreciseVector) Sub(ov PreciseVector) PreciseVector {
return PreciseVector{
X: precSub(v.X, ov.X),
Y: precSub(v.Y, ov.Y),
Z: precSub(v.Z, ov.Z),
}
} | go | func (v PreciseVector) Sub(ov PreciseVector) PreciseVector {
return PreciseVector{
X: precSub(v.X, ov.X),
Y: precSub(v.Y, ov.Y),
Z: precSub(v.Z, ov.Z),
}
} | [
"func",
"(",
"v",
"PreciseVector",
")",
"Sub",
"(",
"ov",
"PreciseVector",
")",
"PreciseVector",
"{",
"return",
"PreciseVector",
"{",
"X",
":",
"precSub",
"(",
"v",
".",
"X",
",",
"ov",
".",
"X",
")",
",",
"Y",
":",
"precSub",
"(",
"v",
".",
"Y",
... | // Sub returns the standard vector difference of v and ov. | [
"Sub",
"returns",
"the",
"standard",
"vector",
"difference",
"of",
"v",
"and",
"ov",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L132-L138 |
28,225 | golang/geo | r3/precisevector.go | Mul | func (v PreciseVector) Mul(f *big.Float) PreciseVector {
return PreciseVector{
X: precMul(v.X, f),
Y: precMul(v.Y, f),
Z: precMul(v.Z, f),
}
} | go | func (v PreciseVector) Mul(f *big.Float) PreciseVector {
return PreciseVector{
X: precMul(v.X, f),
Y: precMul(v.Y, f),
Z: precMul(v.Z, f),
}
} | [
"func",
"(",
"v",
"PreciseVector",
")",
"Mul",
"(",
"f",
"*",
"big",
".",
"Float",
")",
"PreciseVector",
"{",
"return",
"PreciseVector",
"{",
"X",
":",
"precMul",
"(",
"v",
".",
"X",
",",
"f",
")",
",",
"Y",
":",
"precMul",
"(",
"v",
".",
"Y",
... | // Mul returns the standard scalar product of v and f. | [
"Mul",
"returns",
"the",
"standard",
"scalar",
"product",
"of",
"v",
"and",
"f",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L141-L147 |
28,226 | golang/geo | r3/precisevector.go | MulByFloat64 | func (v PreciseVector) MulByFloat64(f float64) PreciseVector {
return v.Mul(precFloat(f))
} | go | func (v PreciseVector) MulByFloat64(f float64) PreciseVector {
return v.Mul(precFloat(f))
} | [
"func",
"(",
"v",
"PreciseVector",
")",
"MulByFloat64",
"(",
"f",
"float64",
")",
"PreciseVector",
"{",
"return",
"v",
".",
"Mul",
"(",
"precFloat",
"(",
"f",
")",
")",
"\n",
"}"
] | // MulByFloat64 returns the standard scalar product of v and f. | [
"MulByFloat64",
"returns",
"the",
"standard",
"scalar",
"product",
"of",
"v",
"and",
"f",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L150-L152 |
28,227 | golang/geo | r3/precisevector.go | Dot | func (v PreciseVector) Dot(ov PreciseVector) *big.Float {
return precAdd(precMul(v.X, ov.X), precAdd(precMul(v.Y, ov.Y), precMul(v.Z, ov.Z)))
} | go | func (v PreciseVector) Dot(ov PreciseVector) *big.Float {
return precAdd(precMul(v.X, ov.X), precAdd(precMul(v.Y, ov.Y), precMul(v.Z, ov.Z)))
} | [
"func",
"(",
"v",
"PreciseVector",
")",
"Dot",
"(",
"ov",
"PreciseVector",
")",
"*",
"big",
".",
"Float",
"{",
"return",
"precAdd",
"(",
"precMul",
"(",
"v",
".",
"X",
",",
"ov",
".",
"X",
")",
",",
"precAdd",
"(",
"precMul",
"(",
"v",
".",
"Y",
... | // Dot returns the standard dot product of v and ov. | [
"Dot",
"returns",
"the",
"standard",
"dot",
"product",
"of",
"v",
"and",
"ov",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r3/precisevector.go#L155-L157 |
28,228 | golang/geo | s2/matrix3x3.go | col | func (m *matrix3x3) col(col int) Point {
return Point{r3.Vector{m[0][col], m[1][col], m[2][col]}}
} | go | func (m *matrix3x3) col(col int) Point {
return Point{r3.Vector{m[0][col], m[1][col], m[2][col]}}
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"col",
"(",
"col",
"int",
")",
"Point",
"{",
"return",
"Point",
"{",
"r3",
".",
"Vector",
"{",
"m",
"[",
"0",
"]",
"[",
"col",
"]",
",",
"m",
"[",
"1",
"]",
"[",
"col",
"]",
",",
"m",
"[",
"2",
"]"... | // col returns the given column as a Point. | [
"col",
"returns",
"the",
"given",
"column",
"as",
"a",
"Point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L29-L31 |
28,229 | golang/geo | s2/matrix3x3.go | row | func (m *matrix3x3) row(row int) Point {
return Point{r3.Vector{m[row][0], m[row][1], m[row][2]}}
} | go | func (m *matrix3x3) row(row int) Point {
return Point{r3.Vector{m[row][0], m[row][1], m[row][2]}}
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"row",
"(",
"row",
"int",
")",
"Point",
"{",
"return",
"Point",
"{",
"r3",
".",
"Vector",
"{",
"m",
"[",
"row",
"]",
"[",
"0",
"]",
",",
"m",
"[",
"row",
"]",
"[",
"1",
"]",
",",
"m",
"[",
"row",
"... | // row returns the given row as a Point. | [
"row",
"returns",
"the",
"given",
"row",
"as",
"a",
"Point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L34-L36 |
28,230 | golang/geo | s2/matrix3x3.go | setCol | func (m *matrix3x3) setCol(col int, p Point) *matrix3x3 {
m[0][col] = p.X
m[1][col] = p.Y
m[2][col] = p.Z
return m
} | go | func (m *matrix3x3) setCol(col int, p Point) *matrix3x3 {
m[0][col] = p.X
m[1][col] = p.Y
m[2][col] = p.Z
return m
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"setCol",
"(",
"col",
"int",
",",
"p",
"Point",
")",
"*",
"matrix3x3",
"{",
"m",
"[",
"0",
"]",
"[",
"col",
"]",
"=",
"p",
".",
"X",
"\n",
"m",
"[",
"1",
"]",
"[",
"col",
"]",
"=",
"p",
".",
"Y",
... | // setCol sets the specified column to the value in the given Point. | [
"setCol",
"sets",
"the",
"specified",
"column",
"to",
"the",
"value",
"in",
"the",
"given",
"Point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L39-L45 |
28,231 | golang/geo | s2/matrix3x3.go | setRow | func (m *matrix3x3) setRow(row int, p Point) *matrix3x3 {
m[row][0] = p.X
m[row][1] = p.Y
m[row][2] = p.Z
return m
} | go | func (m *matrix3x3) setRow(row int, p Point) *matrix3x3 {
m[row][0] = p.X
m[row][1] = p.Y
m[row][2] = p.Z
return m
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"setRow",
"(",
"row",
"int",
",",
"p",
"Point",
")",
"*",
"matrix3x3",
"{",
"m",
"[",
"row",
"]",
"[",
"0",
"]",
"=",
"p",
".",
"X",
"\n",
"m",
"[",
"row",
"]",
"[",
"1",
"]",
"=",
"p",
".",
"Y",
... | // setRow sets the specified row to the value in the given Point. | [
"setRow",
"sets",
"the",
"specified",
"row",
"to",
"the",
"value",
"in",
"the",
"given",
"Point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L48-L54 |
28,232 | golang/geo | s2/matrix3x3.go | scale | func (m *matrix3x3) scale(f float64) *matrix3x3 {
return &matrix3x3{
[3]float64{f * m[0][0], f * m[0][1], f * m[0][2]},
[3]float64{f * m[1][0], f * m[1][1], f * m[1][2]},
[3]float64{f * m[2][0], f * m[2][1], f * m[2][2]},
}
} | go | func (m *matrix3x3) scale(f float64) *matrix3x3 {
return &matrix3x3{
[3]float64{f * m[0][0], f * m[0][1], f * m[0][2]},
[3]float64{f * m[1][0], f * m[1][1], f * m[1][2]},
[3]float64{f * m[2][0], f * m[2][1], f * m[2][2]},
}
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"scale",
"(",
"f",
"float64",
")",
"*",
"matrix3x3",
"{",
"return",
"&",
"matrix3x3",
"{",
"[",
"3",
"]",
"float64",
"{",
"f",
"*",
"m",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"f",
"*",
"m",
"[",
"0",
"]... | // scale multiplies the matrix by the given value. | [
"scale",
"multiplies",
"the",
"matrix",
"by",
"the",
"given",
"value",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L57-L63 |
28,233 | golang/geo | s2/matrix3x3.go | mul | func (m *matrix3x3) mul(p Point) Point {
return Point{r3.Vector{
m[0][0]*p.X + m[0][1]*p.Y + m[0][2]*p.Z,
m[1][0]*p.X + m[1][1]*p.Y + m[1][2]*p.Z,
m[2][0]*p.X + m[2][1]*p.Y + m[2][2]*p.Z,
}}
} | go | func (m *matrix3x3) mul(p Point) Point {
return Point{r3.Vector{
m[0][0]*p.X + m[0][1]*p.Y + m[0][2]*p.Z,
m[1][0]*p.X + m[1][1]*p.Y + m[1][2]*p.Z,
m[2][0]*p.X + m[2][1]*p.Y + m[2][2]*p.Z,
}}
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"mul",
"(",
"p",
"Point",
")",
"Point",
"{",
"return",
"Point",
"{",
"r3",
".",
"Vector",
"{",
"m",
"[",
"0",
"]",
"[",
"0",
"]",
"*",
"p",
".",
"X",
"+",
"m",
"[",
"0",
"]",
"[",
"1",
"]",
"*",
... | // mul returns the multiplication of m by the Point p and converts the
// resulting 1x3 matrix into a Point. | [
"mul",
"returns",
"the",
"multiplication",
"of",
"m",
"by",
"the",
"Point",
"p",
"and",
"converts",
"the",
"resulting",
"1x3",
"matrix",
"into",
"a",
"Point",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L67-L73 |
28,234 | golang/geo | s2/matrix3x3.go | det | func (m *matrix3x3) det() float64 {
// | a b c |
// det | d e f | = aei + bfg + cdh - ceg - bdi - afh
// | g h i |
return m[0][0]*m[1][1]*m[2][2] + m[0][1]*m[1][2]*m[2][0] + m[0][2]*m[1][0]*m[2][1] -
m[0][2]*m[1][1]*m[2][0] - m[0][1]*m[1][0]*m[2][2] - m[0][0]*m[1][2]*m[2][1]
} | go | func (m *matrix3x3) det() float64 {
// | a b c |
// det | d e f | = aei + bfg + cdh - ceg - bdi - afh
// | g h i |
return m[0][0]*m[1][1]*m[2][2] + m[0][1]*m[1][2]*m[2][0] + m[0][2]*m[1][0]*m[2][1] -
m[0][2]*m[1][1]*m[2][0] - m[0][1]*m[1][0]*m[2][2] - m[0][0]*m[1][2]*m[2][1]
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"det",
"(",
")",
"float64",
"{",
"// | a b c |",
"// det | d e f | = aei + bfg + cdh - ceg - bdi - afh",
"// | g h i |",
"return",
"m",
"[",
"0",
"]",
"[",
"0",
"]",
"*",
"m",
"[",
"1",
"]",
"[",
"1",
... | // det returns the determinant of this matrix. | [
"det",
"returns",
"the",
"determinant",
"of",
"this",
"matrix",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L76-L82 |
28,235 | golang/geo | s2/matrix3x3.go | transpose | func (m *matrix3x3) transpose() *matrix3x3 {
m[0][1], m[1][0] = m[1][0], m[0][1]
m[0][2], m[2][0] = m[2][0], m[0][2]
m[1][2], m[2][1] = m[2][1], m[1][2]
return m
} | go | func (m *matrix3x3) transpose() *matrix3x3 {
m[0][1], m[1][0] = m[1][0], m[0][1]
m[0][2], m[2][0] = m[2][0], m[0][2]
m[1][2], m[2][1] = m[2][1], m[1][2]
return m
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"transpose",
"(",
")",
"*",
"matrix3x3",
"{",
"m",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"m",
"[",
"1",
"]",
"[",
"0",
"]",
"=",
"m",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"m",
"[",
"0",
"]",
"[",
"1... | // transpose reflects the matrix along its diagonal and returns the result. | [
"transpose",
"reflects",
"the",
"matrix",
"along",
"its",
"diagonal",
"and",
"returns",
"the",
"result",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L85-L91 |
28,236 | golang/geo | s2/matrix3x3.go | String | func (m *matrix3x3) String() string {
return fmt.Sprintf("[ %0.4f %0.4f %0.4f ] [ %0.4f %0.4f %0.4f ] [ %0.4f %0.4f %0.4f ]",
m[0][0], m[0][1], m[0][2],
m[1][0], m[1][1], m[1][2],
m[2][0], m[2][1], m[2][2],
)
} | go | func (m *matrix3x3) String() string {
return fmt.Sprintf("[ %0.4f %0.4f %0.4f ] [ %0.4f %0.4f %0.4f ] [ %0.4f %0.4f %0.4f ]",
m[0][0], m[0][1], m[0][2],
m[1][0], m[1][1], m[1][2],
m[2][0], m[2][1], m[2][2],
)
} | [
"func",
"(",
"m",
"*",
"matrix3x3",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"m",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"m",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"m",
"[",
"0",
"]",
"[",
... | // String formats the matrix into an easier to read layout. | [
"String",
"formats",
"the",
"matrix",
"into",
"an",
"easier",
"to",
"read",
"layout",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L94-L100 |
28,237 | golang/geo | s2/matrix3x3.go | getFrame | func getFrame(p Point) matrix3x3 {
// Given the point p on the unit sphere, extend this into a right-handed
// coordinate frame of unit-length column vectors m = (x,y,z). Note that
// the vectors (x,y) are an orthonormal frame for the tangent space at point p,
// while p itself is an orthonormal frame for the norm... | go | func getFrame(p Point) matrix3x3 {
// Given the point p on the unit sphere, extend this into a right-handed
// coordinate frame of unit-length column vectors m = (x,y,z). Note that
// the vectors (x,y) are an orthonormal frame for the tangent space at point p,
// while p itself is an orthonormal frame for the norm... | [
"func",
"getFrame",
"(",
"p",
"Point",
")",
"matrix3x3",
"{",
"// Given the point p on the unit sphere, extend this into a right-handed",
"// coordinate frame of unit-length column vectors m = (x,y,z). Note that",
"// the vectors (x,y) are an orthonormal frame for the tangent space at point p,"... | // getFrame returns the orthonormal frame for the given point on the unit sphere. | [
"getFrame",
"returns",
"the",
"orthonormal",
"frame",
"for",
"the",
"given",
"point",
"on",
"the",
"unit",
"sphere",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/matrix3x3.go#L103-L113 |
28,238 | golang/geo | r2/rect.go | Normalize | func (p Point) Normalize() Point {
if p.X == 0 && p.Y == 0 {
return p
}
return p.Mul(1 / p.Norm())
} | go | func (p Point) Normalize() Point {
if p.X == 0 && p.Y == 0 {
return p
}
return p.Mul(1 / p.Norm())
} | [
"func",
"(",
"p",
"Point",
")",
"Normalize",
"(",
")",
"Point",
"{",
"if",
"p",
".",
"X",
"==",
"0",
"&&",
"p",
".",
"Y",
"==",
"0",
"{",
"return",
"p",
"\n",
"}",
"\n",
"return",
"p",
".",
"Mul",
"(",
"1",
"/",
"p",
".",
"Norm",
"(",
")"... | // Normalize returns a unit point in the same direction as p. | [
"Normalize",
"returns",
"a",
"unit",
"point",
"in",
"the",
"same",
"direction",
"as",
"p",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L51-L56 |
28,239 | golang/geo | r2/rect.go | RectFromPoints | func RectFromPoints(pts ...Point) Rect {
// Because the default value on interval is 0,0, we need to manually
// define the interval from the first point passed in as our starting
// interval, otherwise we end up with the case of passing in
// Point{0.2, 0.3} and getting the starting Rect of {0, 0.2}, {0, 0.3}
// ... | go | func RectFromPoints(pts ...Point) Rect {
// Because the default value on interval is 0,0, we need to manually
// define the interval from the first point passed in as our starting
// interval, otherwise we end up with the case of passing in
// Point{0.2, 0.3} and getting the starting Rect of {0, 0.2}, {0, 0.3}
// ... | [
"func",
"RectFromPoints",
"(",
"pts",
"...",
"Point",
")",
"Rect",
"{",
"// Because the default value on interval is 0,0, we need to manually",
"// define the interval from the first point passed in as our starting",
"// interval, otherwise we end up with the case of passing in",
"// Point{0... | // RectFromPoints constructs a rect that contains the given points. | [
"RectFromPoints",
"constructs",
"a",
"rect",
"that",
"contains",
"the",
"given",
"points",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L66-L85 |
28,240 | golang/geo | r2/rect.go | RectFromCenterSize | func RectFromCenterSize(center, size Point) Rect {
return Rect{
r1.Interval{Lo: center.X - size.X/2, Hi: center.X + size.X/2},
r1.Interval{Lo: center.Y - size.Y/2, Hi: center.Y + size.Y/2},
}
} | go | func RectFromCenterSize(center, size Point) Rect {
return Rect{
r1.Interval{Lo: center.X - size.X/2, Hi: center.X + size.X/2},
r1.Interval{Lo: center.Y - size.Y/2, Hi: center.Y + size.Y/2},
}
} | [
"func",
"RectFromCenterSize",
"(",
"center",
",",
"size",
"Point",
")",
"Rect",
"{",
"return",
"Rect",
"{",
"r1",
".",
"Interval",
"{",
"Lo",
":",
"center",
".",
"X",
"-",
"size",
".",
"X",
"/",
"2",
",",
"Hi",
":",
"center",
".",
"X",
"+",
"size... | // RectFromCenterSize constructs a rectangle with the given center and size.
// Both dimensions of size must be non-negative. | [
"RectFromCenterSize",
"constructs",
"a",
"rectangle",
"with",
"the",
"given",
"center",
"and",
"size",
".",
"Both",
"dimensions",
"of",
"size",
"must",
"be",
"non",
"-",
"negative",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L89-L94 |
28,241 | golang/geo | r2/rect.go | IsValid | func (r Rect) IsValid() bool {
return r.X.IsEmpty() == r.Y.IsEmpty()
} | go | func (r Rect) IsValid() bool {
return r.X.IsEmpty() == r.Y.IsEmpty()
} | [
"func",
"(",
"r",
"Rect",
")",
"IsValid",
"(",
")",
"bool",
"{",
"return",
"r",
".",
"X",
".",
"IsEmpty",
"(",
")",
"==",
"r",
".",
"Y",
".",
"IsEmpty",
"(",
")",
"\n",
"}"
] | // IsValid reports whether the rectangle is valid.
// This requires the width to be empty iff the height is empty. | [
"IsValid",
"reports",
"whether",
"the",
"rectangle",
"is",
"valid",
".",
"This",
"requires",
"the",
"width",
"to",
"be",
"empty",
"iff",
"the",
"height",
"is",
"empty",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L105-L107 |
28,242 | golang/geo | r2/rect.go | Vertices | func (r Rect) Vertices() [4]Point {
return [4]Point{
{r.X.Lo, r.Y.Lo},
{r.X.Hi, r.Y.Lo},
{r.X.Hi, r.Y.Hi},
{r.X.Lo, r.Y.Hi},
}
} | go | func (r Rect) Vertices() [4]Point {
return [4]Point{
{r.X.Lo, r.Y.Lo},
{r.X.Hi, r.Y.Lo},
{r.X.Hi, r.Y.Hi},
{r.X.Lo, r.Y.Hi},
}
} | [
"func",
"(",
"r",
"Rect",
")",
"Vertices",
"(",
")",
"[",
"4",
"]",
"Point",
"{",
"return",
"[",
"4",
"]",
"Point",
"{",
"{",
"r",
".",
"X",
".",
"Lo",
",",
"r",
".",
"Y",
".",
"Lo",
"}",
",",
"{",
"r",
".",
"X",
".",
"Hi",
",",
"r",
... | // Vertices returns all four vertices of the rectangle. Vertices are returned in
// CCW direction starting with the lower left corner. | [
"Vertices",
"returns",
"all",
"four",
"vertices",
"of",
"the",
"rectangle",
".",
"Vertices",
"are",
"returned",
"in",
"CCW",
"direction",
"starting",
"with",
"the",
"lower",
"left",
"corner",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L116-L123 |
28,243 | golang/geo | r2/rect.go | Lo | func (r Rect) Lo() Point {
return Point{r.X.Lo, r.Y.Lo}
} | go | func (r Rect) Lo() Point {
return Point{r.X.Lo, r.Y.Lo}
} | [
"func",
"(",
"r",
"Rect",
")",
"Lo",
"(",
")",
"Point",
"{",
"return",
"Point",
"{",
"r",
".",
"X",
".",
"Lo",
",",
"r",
".",
"Y",
".",
"Lo",
"}",
"\n",
"}"
] | // Lo returns the low corner of the rect. | [
"Lo",
"returns",
"the",
"low",
"corner",
"of",
"the",
"rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L140-L142 |
28,244 | golang/geo | r2/rect.go | Hi | func (r Rect) Hi() Point {
return Point{r.X.Hi, r.Y.Hi}
} | go | func (r Rect) Hi() Point {
return Point{r.X.Hi, r.Y.Hi}
} | [
"func",
"(",
"r",
"Rect",
")",
"Hi",
"(",
")",
"Point",
"{",
"return",
"Point",
"{",
"r",
".",
"X",
".",
"Hi",
",",
"r",
".",
"Y",
".",
"Hi",
"}",
"\n",
"}"
] | // Hi returns the high corner of the rect. | [
"Hi",
"returns",
"the",
"high",
"corner",
"of",
"the",
"rect",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L145-L147 |
28,245 | golang/geo | r2/rect.go | ContainsPoint | func (r Rect) ContainsPoint(p Point) bool {
return r.X.Contains(p.X) && r.Y.Contains(p.Y)
} | go | func (r Rect) ContainsPoint(p Point) bool {
return r.X.Contains(p.X) && r.Y.Contains(p.Y)
} | [
"func",
"(",
"r",
"Rect",
")",
"ContainsPoint",
"(",
"p",
"Point",
")",
"bool",
"{",
"return",
"r",
".",
"X",
".",
"Contains",
"(",
"p",
".",
"X",
")",
"&&",
"r",
".",
"Y",
".",
"Contains",
"(",
"p",
".",
"Y",
")",
"\n",
"}"
] | // ContainsPoint reports whether the rectangle contains the given point.
// Rectangles are closed regions, i.e. they contain their boundary. | [
"ContainsPoint",
"reports",
"whether",
"the",
"rectangle",
"contains",
"the",
"given",
"point",
".",
"Rectangles",
"are",
"closed",
"regions",
"i",
".",
"e",
".",
"they",
"contain",
"their",
"boundary",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L162-L164 |
28,246 | golang/geo | r2/rect.go | Contains | func (r Rect) Contains(other Rect) bool {
return r.X.ContainsInterval(other.X) && r.Y.ContainsInterval(other.Y)
} | go | func (r Rect) Contains(other Rect) bool {
return r.X.ContainsInterval(other.X) && r.Y.ContainsInterval(other.Y)
} | [
"func",
"(",
"r",
"Rect",
")",
"Contains",
"(",
"other",
"Rect",
")",
"bool",
"{",
"return",
"r",
".",
"X",
".",
"ContainsInterval",
"(",
"other",
".",
"X",
")",
"&&",
"r",
".",
"Y",
".",
"ContainsInterval",
"(",
"other",
".",
"Y",
")",
"\n",
"}"... | // Contains reports whether the rectangle contains the given rectangle. | [
"Contains",
"reports",
"whether",
"the",
"rectangle",
"contains",
"the",
"given",
"rectangle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L173-L175 |
28,247 | golang/geo | r2/rect.go | Intersects | func (r Rect) Intersects(other Rect) bool {
return r.X.Intersects(other.X) && r.Y.Intersects(other.Y)
} | go | func (r Rect) Intersects(other Rect) bool {
return r.X.Intersects(other.X) && r.Y.Intersects(other.Y)
} | [
"func",
"(",
"r",
"Rect",
")",
"Intersects",
"(",
"other",
"Rect",
")",
"bool",
"{",
"return",
"r",
".",
"X",
".",
"Intersects",
"(",
"other",
".",
"X",
")",
"&&",
"r",
".",
"Y",
".",
"Intersects",
"(",
"other",
".",
"Y",
")",
"\n",
"}"
] | // Intersects reports whether this rectangle and the other rectangle have any points in common. | [
"Intersects",
"reports",
"whether",
"this",
"rectangle",
"and",
"the",
"other",
"rectangle",
"have",
"any",
"points",
"in",
"common",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L184-L186 |
28,248 | golang/geo | r2/rect.go | AddPoint | func (r Rect) AddPoint(p Point) Rect {
return Rect{r.X.AddPoint(p.X), r.Y.AddPoint(p.Y)}
} | go | func (r Rect) AddPoint(p Point) Rect {
return Rect{r.X.AddPoint(p.X), r.Y.AddPoint(p.Y)}
} | [
"func",
"(",
"r",
"Rect",
")",
"AddPoint",
"(",
"p",
"Point",
")",
"Rect",
"{",
"return",
"Rect",
"{",
"r",
".",
"X",
".",
"AddPoint",
"(",
"p",
".",
"X",
")",
",",
"r",
".",
"Y",
".",
"AddPoint",
"(",
"p",
".",
"Y",
")",
"}",
"\n",
"}"
] | // AddPoint expands the rectangle to include the given point. The rectangle is
// expanded by the minimum amount possible. | [
"AddPoint",
"expands",
"the",
"rectangle",
"to",
"include",
"the",
"given",
"point",
".",
"The",
"rectangle",
"is",
"expanded",
"by",
"the",
"minimum",
"amount",
"possible",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L196-L198 |
28,249 | golang/geo | r2/rect.go | ClampPoint | func (r Rect) ClampPoint(p Point) Point {
return Point{r.X.ClampPoint(p.X), r.Y.ClampPoint(p.Y)}
} | go | func (r Rect) ClampPoint(p Point) Point {
return Point{r.X.ClampPoint(p.X), r.Y.ClampPoint(p.Y)}
} | [
"func",
"(",
"r",
"Rect",
")",
"ClampPoint",
"(",
"p",
"Point",
")",
"Point",
"{",
"return",
"Point",
"{",
"r",
".",
"X",
".",
"ClampPoint",
"(",
"p",
".",
"X",
")",
",",
"r",
".",
"Y",
".",
"ClampPoint",
"(",
"p",
".",
"Y",
")",
"}",
"\n",
... | // ClampPoint returns the closest point in the rectangle to the given point.
// The rectangle must be non-empty. | [
"ClampPoint",
"returns",
"the",
"closest",
"point",
"in",
"the",
"rectangle",
"to",
"the",
"given",
"point",
".",
"The",
"rectangle",
"must",
"be",
"non",
"-",
"empty",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L209-L211 |
28,250 | golang/geo | r2/rect.go | Expanded | func (r Rect) Expanded(margin Point) Rect {
xx := r.X.Expanded(margin.X)
yy := r.Y.Expanded(margin.Y)
if xx.IsEmpty() || yy.IsEmpty() {
return EmptyRect()
}
return Rect{xx, yy}
} | go | func (r Rect) Expanded(margin Point) Rect {
xx := r.X.Expanded(margin.X)
yy := r.Y.Expanded(margin.Y)
if xx.IsEmpty() || yy.IsEmpty() {
return EmptyRect()
}
return Rect{xx, yy}
} | [
"func",
"(",
"r",
"Rect",
")",
"Expanded",
"(",
"margin",
"Point",
")",
"Rect",
"{",
"xx",
":=",
"r",
".",
"X",
".",
"Expanded",
"(",
"margin",
".",
"X",
")",
"\n",
"yy",
":=",
"r",
".",
"Y",
".",
"Expanded",
"(",
"margin",
".",
"Y",
")",
"\n... | // Expanded returns a rectangle that has been expanded in the x-direction
// by margin.X, and in y-direction by margin.Y. If either margin is empty,
// then shrink the interval on the corresponding sides instead. The resulting
// rectangle may be empty. Any expansion of an empty rectangle remains empty. | [
"Expanded",
"returns",
"a",
"rectangle",
"that",
"has",
"been",
"expanded",
"in",
"the",
"x",
"-",
"direction",
"by",
"margin",
".",
"X",
"and",
"in",
"y",
"-",
"direction",
"by",
"margin",
".",
"Y",
".",
"If",
"either",
"margin",
"is",
"empty",
"then"... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L217-L224 |
28,251 | golang/geo | r2/rect.go | ExpandedByMargin | func (r Rect) ExpandedByMargin(margin float64) Rect {
return r.Expanded(Point{margin, margin})
} | go | func (r Rect) ExpandedByMargin(margin float64) Rect {
return r.Expanded(Point{margin, margin})
} | [
"func",
"(",
"r",
"Rect",
")",
"ExpandedByMargin",
"(",
"margin",
"float64",
")",
"Rect",
"{",
"return",
"r",
".",
"Expanded",
"(",
"Point",
"{",
"margin",
",",
"margin",
"}",
")",
"\n",
"}"
] | // ExpandedByMargin returns a Rect that has been expanded by the amount on all sides. | [
"ExpandedByMargin",
"returns",
"a",
"Rect",
"that",
"has",
"been",
"expanded",
"by",
"the",
"amount",
"on",
"all",
"sides",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L227-L229 |
28,252 | golang/geo | r2/rect.go | Union | func (r Rect) Union(other Rect) Rect {
return Rect{r.X.Union(other.X), r.Y.Union(other.Y)}
} | go | func (r Rect) Union(other Rect) Rect {
return Rect{r.X.Union(other.X), r.Y.Union(other.Y)}
} | [
"func",
"(",
"r",
"Rect",
")",
"Union",
"(",
"other",
"Rect",
")",
"Rect",
"{",
"return",
"Rect",
"{",
"r",
".",
"X",
".",
"Union",
"(",
"other",
".",
"X",
")",
",",
"r",
".",
"Y",
".",
"Union",
"(",
"other",
".",
"Y",
")",
"}",
"\n",
"}"
] | // Union returns the smallest rectangle containing the union of this rectangle and
// the given rectangle. | [
"Union",
"returns",
"the",
"smallest",
"rectangle",
"containing",
"the",
"union",
"of",
"this",
"rectangle",
"and",
"the",
"given",
"rectangle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L233-L235 |
28,253 | golang/geo | r2/rect.go | Intersection | func (r Rect) Intersection(other Rect) Rect {
xx := r.X.Intersection(other.X)
yy := r.Y.Intersection(other.Y)
if xx.IsEmpty() || yy.IsEmpty() {
return EmptyRect()
}
return Rect{xx, yy}
} | go | func (r Rect) Intersection(other Rect) Rect {
xx := r.X.Intersection(other.X)
yy := r.Y.Intersection(other.Y)
if xx.IsEmpty() || yy.IsEmpty() {
return EmptyRect()
}
return Rect{xx, yy}
} | [
"func",
"(",
"r",
"Rect",
")",
"Intersection",
"(",
"other",
"Rect",
")",
"Rect",
"{",
"xx",
":=",
"r",
".",
"X",
".",
"Intersection",
"(",
"other",
".",
"X",
")",
"\n",
"yy",
":=",
"r",
".",
"Y",
".",
"Intersection",
"(",
"other",
".",
"Y",
")... | // Intersection returns the smallest rectangle containing the intersection of this
// rectangle and the given rectangle. | [
"Intersection",
"returns",
"the",
"smallest",
"rectangle",
"containing",
"the",
"intersection",
"of",
"this",
"rectangle",
"and",
"the",
"given",
"rectangle",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/r2/rect.go#L239-L247 |
28,254 | golang/geo | s2/edge_tessellator.go | NewEdgeTessellator | func NewEdgeTessellator(p Projection, tolerance s1.Angle) *EdgeTessellator {
return &EdgeTessellator{
projection: p,
tolerance: s1.ChordAngleFromAngle(maxAngle(tolerance, MinTessellationTolerance)),
wrapDistance: p.WrapDistance(),
}
} | go | func NewEdgeTessellator(p Projection, tolerance s1.Angle) *EdgeTessellator {
return &EdgeTessellator{
projection: p,
tolerance: s1.ChordAngleFromAngle(maxAngle(tolerance, MinTessellationTolerance)),
wrapDistance: p.WrapDistance(),
}
} | [
"func",
"NewEdgeTessellator",
"(",
"p",
"Projection",
",",
"tolerance",
"s1",
".",
"Angle",
")",
"*",
"EdgeTessellator",
"{",
"return",
"&",
"EdgeTessellator",
"{",
"projection",
":",
"p",
",",
"tolerance",
":",
"s1",
".",
"ChordAngleFromAngle",
"(",
"maxAngle... | // NewEdgeTessellator creates a new edge tessellator for the given projection and tolerance. | [
"NewEdgeTessellator",
"creates",
"a",
"new",
"edge",
"tessellator",
"for",
"the",
"given",
"projection",
"and",
"tolerance",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_tessellator.go#L50-L56 |
28,255 | golang/geo | s2/edge_tessellator.go | appendUnprojected | func (e *EdgeTessellator) appendUnprojected(pa r2.Point, a Point, pb r2.Point, b Point, vertices []Point) []Point {
pmid := e.projection.Interpolate(0.5, pa, pb)
mid := e.projection.Unproject(pmid)
testMid := Point{a.Add(b.Vector).Normalize()}
if ChordAngleBetweenPoints(mid, testMid) < e.tolerance {
return appen... | go | func (e *EdgeTessellator) appendUnprojected(pa r2.Point, a Point, pb r2.Point, b Point, vertices []Point) []Point {
pmid := e.projection.Interpolate(0.5, pa, pb)
mid := e.projection.Unproject(pmid)
testMid := Point{a.Add(b.Vector).Normalize()}
if ChordAngleBetweenPoints(mid, testMid) < e.tolerance {
return appen... | [
"func",
"(",
"e",
"*",
"EdgeTessellator",
")",
"appendUnprojected",
"(",
"pa",
"r2",
".",
"Point",
",",
"a",
"Point",
",",
"pb",
"r2",
".",
"Point",
",",
"b",
"Point",
",",
"vertices",
"[",
"]",
"Point",
")",
"[",
"]",
"Point",
"{",
"pmid",
":=",
... | // appendUnprojected interpolates a projected edge and appends the corresponding
// points on the sphere. | [
"appendUnprojected",
"interpolates",
"a",
"projected",
"edge",
"and",
"appends",
"the",
"corresponding",
"points",
"on",
"the",
"sphere",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_tessellator.go#L141-L152 |
28,256 | golang/geo | s2/edge_tessellator.go | wrapDestination | func (e *EdgeTessellator) wrapDestination(pa, pb r2.Point) r2.Point {
x := pb.X
y := pb.Y
// The code below ensures that pb is unmodified unless wrapping is required.
if e.wrapDistance.X > 0 && math.Abs(x-pa.X) > 0.5*e.wrapDistance.X {
x = pa.X + math.Remainder(x-pa.X, e.wrapDistance.X)
}
if e.wrapDistance.Y > ... | go | func (e *EdgeTessellator) wrapDestination(pa, pb r2.Point) r2.Point {
x := pb.X
y := pb.Y
// The code below ensures that pb is unmodified unless wrapping is required.
if e.wrapDistance.X > 0 && math.Abs(x-pa.X) > 0.5*e.wrapDistance.X {
x = pa.X + math.Remainder(x-pa.X, e.wrapDistance.X)
}
if e.wrapDistance.Y > ... | [
"func",
"(",
"e",
"*",
"EdgeTessellator",
")",
"wrapDestination",
"(",
"pa",
",",
"pb",
"r2",
".",
"Point",
")",
"r2",
".",
"Point",
"{",
"x",
":=",
"pb",
".",
"X",
"\n",
"y",
":=",
"pb",
".",
"Y",
"\n",
"// The code below ensures that pb is unmodified u... | // wrapDestination returns the coordinates of the edge destination wrapped if
// necessary to obtain the shortest edge. | [
"wrapDestination",
"returns",
"the",
"coordinates",
"of",
"the",
"edge",
"destination",
"wrapped",
"if",
"necessary",
"to",
"obtain",
"the",
"shortest",
"edge",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/edge_tessellator.go#L156-L167 |
28,257 | golang/geo | s2/shapeutil.go | newRangeIterator | func newRangeIterator(index *ShapeIndex) *rangeIterator {
r := &rangeIterator{
it: index.Iterator(),
}
r.refresh()
return r
} | go | func newRangeIterator(index *ShapeIndex) *rangeIterator {
r := &rangeIterator{
it: index.Iterator(),
}
r.refresh()
return r
} | [
"func",
"newRangeIterator",
"(",
"index",
"*",
"ShapeIndex",
")",
"*",
"rangeIterator",
"{",
"r",
":=",
"&",
"rangeIterator",
"{",
"it",
":",
"index",
".",
"Iterator",
"(",
")",
",",
"}",
"\n",
"r",
".",
"refresh",
"(",
")",
"\n",
"return",
"r",
"\n"... | // newRangeIterator creates a new rangeIterator positioned at the first cell of the given index. | [
"newRangeIterator",
"creates",
"a",
"new",
"rangeIterator",
"positioned",
"at",
"the",
"first",
"cell",
"of",
"the",
"given",
"index",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeutil.go#L45-L51 |
28,258 | golang/geo | s2/shapeutil.go | seekTo | func (r *rangeIterator) seekTo(target *rangeIterator) {
r.it.seek(target.rangeMin)
// If the current cell does not overlap target, it is possible that the
// previous cell is the one we are looking for. This can only happen when
// the previous cell contains target but has a smaller CellID.
if r.it.Done() || r.it.... | go | func (r *rangeIterator) seekTo(target *rangeIterator) {
r.it.seek(target.rangeMin)
// If the current cell does not overlap target, it is possible that the
// previous cell is the one we are looking for. This can only happen when
// the previous cell contains target but has a smaller CellID.
if r.it.Done() || r.it.... | [
"func",
"(",
"r",
"*",
"rangeIterator",
")",
"seekTo",
"(",
"target",
"*",
"rangeIterator",
")",
"{",
"r",
".",
"it",
".",
"seek",
"(",
"target",
".",
"rangeMin",
")",
"\n",
"// If the current cell does not overlap target, it is possible that the",
"// previous cell... | // seekTo positions the iterator at the first cell that overlaps or follows
// the current range minimum of the target iterator, i.e. such that its
// rangeMax >= target.rangeMin. | [
"seekTo",
"positions",
"the",
"iterator",
"at",
"the",
"first",
"cell",
"that",
"overlaps",
"or",
"follows",
"the",
"current",
"range",
"minimum",
"of",
"the",
"target",
"iterator",
"i",
".",
"e",
".",
"such",
"that",
"its",
"rangeMax",
">",
"=",
"target",... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeutil.go#L61-L72 |
28,259 | golang/geo | s2/shapeutil.go | seekBeyond | func (r *rangeIterator) seekBeyond(target *rangeIterator) {
r.it.seek(target.rangeMax.Next())
if !r.it.Done() && r.it.CellID().RangeMin() <= target.rangeMax {
r.it.Next()
}
r.refresh()
} | go | func (r *rangeIterator) seekBeyond(target *rangeIterator) {
r.it.seek(target.rangeMax.Next())
if !r.it.Done() && r.it.CellID().RangeMin() <= target.rangeMax {
r.it.Next()
}
r.refresh()
} | [
"func",
"(",
"r",
"*",
"rangeIterator",
")",
"seekBeyond",
"(",
"target",
"*",
"rangeIterator",
")",
"{",
"r",
".",
"it",
".",
"seek",
"(",
"target",
".",
"rangeMax",
".",
"Next",
"(",
")",
")",
"\n",
"if",
"!",
"r",
".",
"it",
".",
"Done",
"(",
... | // seekBeyond positions the iterator at the first cell that follows the current
// range minimum of the target iterator. i.e. the first cell such that its
// rangeMin > target.rangeMax. | [
"seekBeyond",
"positions",
"the",
"iterator",
"at",
"the",
"first",
"cell",
"that",
"follows",
"the",
"current",
"range",
"minimum",
"of",
"the",
"target",
"iterator",
".",
"i",
".",
"e",
".",
"the",
"first",
"cell",
"such",
"that",
"its",
"rangeMin",
">",... | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeutil.go#L77-L83 |
28,260 | golang/geo | s2/shapeutil.go | refresh | func (r *rangeIterator) refresh() {
r.rangeMin = r.cellID().RangeMin()
r.rangeMax = r.cellID().RangeMax()
} | go | func (r *rangeIterator) refresh() {
r.rangeMin = r.cellID().RangeMin()
r.rangeMax = r.cellID().RangeMax()
} | [
"func",
"(",
"r",
"*",
"rangeIterator",
")",
"refresh",
"(",
")",
"{",
"r",
".",
"rangeMin",
"=",
"r",
".",
"cellID",
"(",
")",
".",
"RangeMin",
"(",
")",
"\n",
"r",
".",
"rangeMax",
"=",
"r",
".",
"cellID",
"(",
")",
".",
"RangeMax",
"(",
")",... | // refresh updates the iterators min and max values. | [
"refresh",
"updates",
"the",
"iterators",
"min",
"and",
"max",
"values",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeutil.go#L86-L89 |
28,261 | golang/geo | s2/shapeutil.go | referencePointAtVertex | func referencePointAtVertex(shape Shape, vTest Point) (ReferencePoint, bool) {
var ref ReferencePoint
// Let P be an unbalanced vertex. Vertex P is defined to be inside the
// region if the region contains a particular direction vector starting from
// P, namely the direction p.Ortho(). This can be calculated usin... | go | func referencePointAtVertex(shape Shape, vTest Point) (ReferencePoint, bool) {
var ref ReferencePoint
// Let P be an unbalanced vertex. Vertex P is defined to be inside the
// region if the region contains a particular direction vector starting from
// P, namely the direction p.Ortho(). This can be calculated usin... | [
"func",
"referencePointAtVertex",
"(",
"shape",
"Shape",
",",
"vTest",
"Point",
")",
"(",
"ReferencePoint",
",",
"bool",
")",
"{",
"var",
"ref",
"ReferencePoint",
"\n\n",
"// Let P be an unbalanced vertex. Vertex P is defined to be inside the",
"// region if the region contai... | // referencePointAtVertex reports whether the given vertex is unbalanced, and
// returns a ReferencePoint indicating if the point is contained.
// Otherwise returns false. | [
"referencePointAtVertex",
"reports",
"whether",
"the",
"given",
"vertex",
"is",
"unbalanced",
"and",
"returns",
"a",
"ReferencePoint",
"indicating",
"if",
"the",
"point",
"is",
"contained",
".",
"Otherwise",
"returns",
"false",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/shapeutil.go#L174-L201 |
28,262 | golang/geo | s2/contains_vertex_query.go | NewContainsVertexQuery | func NewContainsVertexQuery(target Point) *ContainsVertexQuery {
return &ContainsVertexQuery{
target: target,
edgeMap: make(map[Point]int),
}
} | go | func NewContainsVertexQuery(target Point) *ContainsVertexQuery {
return &ContainsVertexQuery{
target: target,
edgeMap: make(map[Point]int),
}
} | [
"func",
"NewContainsVertexQuery",
"(",
"target",
"Point",
")",
"*",
"ContainsVertexQuery",
"{",
"return",
"&",
"ContainsVertexQuery",
"{",
"target",
":",
"target",
",",
"edgeMap",
":",
"make",
"(",
"map",
"[",
"Point",
"]",
"int",
")",
",",
"}",
"\n",
"}"
... | // NewContainsVertexQuery returns a new query for the given vertex whose
// containment will be determined. | [
"NewContainsVertexQuery",
"returns",
"a",
"new",
"query",
"for",
"the",
"given",
"vertex",
"whose",
"containment",
"will",
"be",
"determined",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_vertex_query.go#L31-L36 |
28,263 | golang/geo | s2/contains_vertex_query.go | ContainsVertex | func (q *ContainsVertexQuery) ContainsVertex() int {
// Find the unmatched edge that is immediately clockwise from Ortho(P).
referenceDir := Point{q.target.Ortho()}
bestPoint := referenceDir
bestDir := 0
for k, v := range q.edgeMap {
if v == 0 {
continue // This is a "matched" edge.
}
if OrderedCCW(refe... | go | func (q *ContainsVertexQuery) ContainsVertex() int {
// Find the unmatched edge that is immediately clockwise from Ortho(P).
referenceDir := Point{q.target.Ortho()}
bestPoint := referenceDir
bestDir := 0
for k, v := range q.edgeMap {
if v == 0 {
continue // This is a "matched" edge.
}
if OrderedCCW(refe... | [
"func",
"(",
"q",
"*",
"ContainsVertexQuery",
")",
"ContainsVertex",
"(",
")",
"int",
"{",
"// Find the unmatched edge that is immediately clockwise from Ortho(P).",
"referenceDir",
":=",
"Point",
"{",
"q",
".",
"target",
".",
"Ortho",
"(",
")",
"}",
"\n\n",
"bestPo... | // ContainsVertex reports a +1 if the target vertex is contained, -1 if it is
// not contained, and 0 if the incident edges consisted of matched sibling pairs. | [
"ContainsVertex",
"reports",
"a",
"+",
"1",
"if",
"the",
"target",
"vertex",
"is",
"contained",
"-",
"1",
"if",
"it",
"is",
"not",
"contained",
"and",
"0",
"if",
"the",
"incident",
"edges",
"consisted",
"of",
"matched",
"sibling",
"pairs",
"."
] | 476085157cff9aaeef4d4f124649436542d4114a | https://github.com/golang/geo/blob/476085157cff9aaeef4d4f124649436542d4114a/s2/contains_vertex_query.go#L46-L63 |
28,264 | docopt/docopt.go | examples/config_file/config_file.go | merge | func merge(mapA, mapB map[string]interface{}) map[string]interface{} {
result := make(map[string]interface{})
for k, v := range mapA {
result[k] = v
}
for k, v := range mapB {
if _, ok := result[k]; !ok || result[k] == nil || result[k] == false {
result[k] = v
}
}
return result
} | go | func merge(mapA, mapB map[string]interface{}) map[string]interface{} {
result := make(map[string]interface{})
for k, v := range mapA {
result[k] = v
}
for k, v := range mapB {
if _, ok := result[k]; !ok || result[k] == nil || result[k] == false {
result[k] = v
}
}
return result
} | [
"func",
"merge",
"(",
"mapA",
",",
"mapB",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"result",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
")",
"\n",
"fo... | // merge combines two maps.
// truthiness takes priority over falsiness
// mapA takes priority over mapB | [
"merge",
"combines",
"two",
"maps",
".",
"truthiness",
"takes",
"priority",
"over",
"falsiness",
"mapA",
"takes",
"priority",
"over",
"mapB"
] | ee0de3bc6815ee19d4a46c7eb90f829db0e014b1 | https://github.com/docopt/docopt.go/blob/ee0de3bc6815ee19d4a46c7eb90f829db0e014b1/examples/config_file/config_file.go#L47-L58 |
28,265 | docopt/docopt.go | opts.go | guessUntaggedField | func guessUntaggedField(key string) string {
switch {
case strings.HasPrefix(key, "--") && len(key[2:]) > 1:
return titleCaseDashes(key[2:])
case strings.HasPrefix(key, "-") && len(key[1:]) == 1:
return titleCaseDashes(key[1:])
case strings.HasPrefix(key, "<") && strings.HasSuffix(key, ">"):
key = key[1 : len... | go | func guessUntaggedField(key string) string {
switch {
case strings.HasPrefix(key, "--") && len(key[2:]) > 1:
return titleCaseDashes(key[2:])
case strings.HasPrefix(key, "-") && len(key[1:]) == 1:
return titleCaseDashes(key[1:])
case strings.HasPrefix(key, "<") && strings.HasSuffix(key, ">"):
key = key[1 : len... | [
"func",
"guessUntaggedField",
"(",
"key",
"string",
")",
"string",
"{",
"switch",
"{",
"case",
"strings",
".",
"HasPrefix",
"(",
"key",
",",
"\"",
"\"",
")",
"&&",
"len",
"(",
"key",
"[",
"2",
":",
"]",
")",
">",
"1",
":",
"return",
"titleCaseDashes"... | // Best guess which field.Name in a struct to assign for an option key. | [
"Best",
"guess",
"which",
"field",
".",
"Name",
"in",
"a",
"struct",
"to",
"assign",
"for",
"an",
"option",
"key",
"."
] | ee0de3bc6815ee19d4a46c7eb90f829db0e014b1 | https://github.com/docopt/docopt.go/blob/ee0de3bc6815ee19d4a46c7eb90f829db0e014b1/opts.go#L254-L264 |
28,266 | docopt/docopt.go | token.go | isStringUppercase | func isStringUppercase(s string) bool {
if strings.ToUpper(s) != s {
return false
}
for _, c := range []rune(s) {
if unicode.IsUpper(c) {
return true
}
}
return false
} | go | func isStringUppercase(s string) bool {
if strings.ToUpper(s) != s {
return false
}
for _, c := range []rune(s) {
if unicode.IsUpper(c) {
return true
}
}
return false
} | [
"func",
"isStringUppercase",
"(",
"s",
"string",
")",
"bool",
"{",
"if",
"strings",
".",
"ToUpper",
"(",
"s",
")",
"!=",
"s",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"[",
"]",
"rune",
"(",
"s",
")",
"{",
"i... | // returns true if all cased characters in the string are uppercase
// and there are there is at least one cased charcter | [
"returns",
"true",
"if",
"all",
"cased",
"characters",
"in",
"the",
"string",
"are",
"uppercase",
"and",
"there",
"are",
"there",
"is",
"at",
"least",
"one",
"cased",
"charcter"
] | ee0de3bc6815ee19d4a46c7eb90f829db0e014b1 | https://github.com/docopt/docopt.go/blob/ee0de3bc6815ee19d4a46c7eb90f829db0e014b1/token.go#L116-L126 |
28,267 | rubenv/sql-migrate | sqlparse/sqlparse.go | endsWithSemicolon | func endsWithSemicolon(line string) bool {
prev := ""
scanner := bufio.NewScanner(strings.NewReader(line))
scanner.Split(bufio.ScanWords)
for scanner.Scan() {
word := scanner.Text()
if strings.HasPrefix(word, "--") {
break
}
prev = word
}
return strings.HasSuffix(prev, ";")
} | go | func endsWithSemicolon(line string) bool {
prev := ""
scanner := bufio.NewScanner(strings.NewReader(line))
scanner.Split(bufio.ScanWords)
for scanner.Scan() {
word := scanner.Text()
if strings.HasPrefix(word, "--") {
break
}
prev = word
}
return strings.HasSuffix(prev, ";")
} | [
"func",
"endsWithSemicolon",
"(",
"line",
"string",
")",
"bool",
"{",
"prev",
":=",
"\"",
"\"",
"\n",
"scanner",
":=",
"bufio",
".",
"NewScanner",
"(",
"strings",
".",
"NewReader",
"(",
"line",
")",
")",
"\n",
"scanner",
".",
"Split",
"(",
"bufio",
"."... | // Checks the line to see if the line has a statement-ending semicolon
// or if the line contains a double-dash comment. | [
"Checks",
"the",
"line",
"to",
"see",
"if",
"the",
"line",
"has",
"a",
"statement",
"-",
"ending",
"semicolon",
"or",
"if",
"the",
"line",
"contains",
"a",
"double",
"-",
"dash",
"comment",
"."
] | 54bad0a9b051368ffec9cd2b869789c2b8eaea35 | https://github.com/rubenv/sql-migrate/blob/54bad0a9b051368ffec9cd2b869789c2b8eaea35/sqlparse/sqlparse.go#L47-L62 |
28,268 | rubenv/sql-migrate | migrate.go | Exec | func Exec(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection) (int, error) {
return ExecMax(db, dialect, m, dir, 0)
} | go | func Exec(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection) (int, error) {
return ExecMax(db, dialect, m, dir, 0)
} | [
"func",
"Exec",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"dialect",
"string",
",",
"m",
"MigrationSource",
",",
"dir",
"MigrationDirection",
")",
"(",
"int",
",",
"error",
")",
"{",
"return",
"ExecMax",
"(",
"db",
",",
"dialect",
",",
"m",
",",
"dir",
... | // Execute a set of migrations
//
// Returns the number of applied migrations. | [
"Execute",
"a",
"set",
"of",
"migrations",
"Returns",
"the",
"number",
"of",
"applied",
"migrations",
"."
] | 54bad0a9b051368ffec9cd2b869789c2b8eaea35 | https://github.com/rubenv/sql-migrate/blob/54bad0a9b051368ffec9cd2b869789c2b8eaea35/migrate.go#L365-L367 |
28,269 | rubenv/sql-migrate | migrate.go | PlanMigration | func PlanMigration(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) ([]*PlannedMigration, *gorp.DbMap, error) {
dbMap, err := getMigrationDbMap(db, dialect)
if err != nil {
return nil, nil, err
}
migrations, err := m.FindMigrations()
if err != nil {
return nil, nil, err
}
var... | go | func PlanMigration(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) ([]*PlannedMigration, *gorp.DbMap, error) {
dbMap, err := getMigrationDbMap(db, dialect)
if err != nil {
return nil, nil, err
}
migrations, err := m.FindMigrations()
if err != nil {
return nil, nil, err
}
var... | [
"func",
"PlanMigration",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"dialect",
"string",
",",
"m",
"MigrationSource",
",",
"dir",
"MigrationDirection",
",",
"max",
"int",
")",
"(",
"[",
"]",
"*",
"PlannedMigration",
",",
"*",
"gorp",
".",
"DbMap",
",",
"er... | // Plan a migration. | [
"Plan",
"a",
"migration",
"."
] | 54bad0a9b051368ffec9cd2b869789c2b8eaea35 | https://github.com/rubenv/sql-migrate/blob/54bad0a9b051368ffec9cd2b869789c2b8eaea35/migrate.go#L445-L521 |
28,270 | rubenv/sql-migrate | migrate.go | SkipMax | func SkipMax(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) (int, error) {
migrations, dbMap, err := PlanMigration(db, dialect, m, dir, max)
if err != nil {
return 0, err
}
// Skip migrations
applied := 0
for _, migration := range migrations {
var executor SqlExecutor
if m... | go | func SkipMax(db *sql.DB, dialect string, m MigrationSource, dir MigrationDirection, max int) (int, error) {
migrations, dbMap, err := PlanMigration(db, dialect, m, dir, max)
if err != nil {
return 0, err
}
// Skip migrations
applied := 0
for _, migration := range migrations {
var executor SqlExecutor
if m... | [
"func",
"SkipMax",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"dialect",
"string",
",",
"m",
"MigrationSource",
",",
"dir",
"MigrationDirection",
",",
"max",
"int",
")",
"(",
"int",
",",
"error",
")",
"{",
"migrations",
",",
"dbMap",
",",
"err",
":=",
"P... | // Skip a set of migrations
//
// Will skip at most `max` migrations. Pass 0 for no limit.
//
// Returns the number of skipped migrations. | [
"Skip",
"a",
"set",
"of",
"migrations",
"Will",
"skip",
"at",
"most",
"max",
"migrations",
".",
"Pass",
"0",
"for",
"no",
"limit",
".",
"Returns",
"the",
"number",
"of",
"skipped",
"migrations",
"."
] | 54bad0a9b051368ffec9cd2b869789c2b8eaea35 | https://github.com/rubenv/sql-migrate/blob/54bad0a9b051368ffec9cd2b869789c2b8eaea35/migrate.go#L528-L570 |
28,271 | rubenv/sql-migrate | migrate.go | ToApply | func ToApply(migrations []*Migration, current string, direction MigrationDirection) []*Migration {
var index = -1
if current != "" {
for index < len(migrations)-1 {
index++
if migrations[index].Id == current {
break
}
}
}
if direction == Up {
return migrations[index+1:]
} else if direction == D... | go | func ToApply(migrations []*Migration, current string, direction MigrationDirection) []*Migration {
var index = -1
if current != "" {
for index < len(migrations)-1 {
index++
if migrations[index].Id == current {
break
}
}
}
if direction == Up {
return migrations[index+1:]
} else if direction == D... | [
"func",
"ToApply",
"(",
"migrations",
"[",
"]",
"*",
"Migration",
",",
"current",
"string",
",",
"direction",
"MigrationDirection",
")",
"[",
"]",
"*",
"Migration",
"{",
"var",
"index",
"=",
"-",
"1",
"\n",
"if",
"current",
"!=",
"\"",
"\"",
"{",
"for"... | // Filter a slice of migrations into ones that should be applied. | [
"Filter",
"a",
"slice",
"of",
"migrations",
"into",
"ones",
"that",
"should",
"be",
"applied",
"."
] | 54bad0a9b051368ffec9cd2b869789c2b8eaea35 | https://github.com/rubenv/sql-migrate/blob/54bad0a9b051368ffec9cd2b869789c2b8eaea35/migrate.go#L573-L600 |
28,272 | cheekybits/genny | examples/queue/queue_generic.go | Enq | func (q *GenericQueue) Enq(obj Generic) *GenericQueue {
q.items = append(q.items, obj)
return q
} | go | func (q *GenericQueue) Enq(obj Generic) *GenericQueue {
q.items = append(q.items, obj)
return q
} | [
"func",
"(",
"q",
"*",
"GenericQueue",
")",
"Enq",
"(",
"obj",
"Generic",
")",
"*",
"GenericQueue",
"{",
"q",
".",
"items",
"=",
"append",
"(",
"q",
".",
"items",
",",
"obj",
")",
"\n",
"return",
"q",
"\n",
"}"
] | // Enq adds an item to the queue. | [
"Enq",
"adds",
"an",
"item",
"to",
"the",
"queue",
"."
] | d2cf3cdd35ce0d789056c4bc02a4d6349c947caf | https://github.com/cheekybits/genny/blob/d2cf3cdd35ce0d789056c4bc02a4d6349c947caf/examples/queue/queue_generic.go#L18-L21 |
28,273 | cheekybits/genny | examples/queue/queue_generic.go | Deq | func (q *GenericQueue) Deq() Generic {
obj := q.items[0]
q.items = q.items[1:]
return obj
} | go | func (q *GenericQueue) Deq() Generic {
obj := q.items[0]
q.items = q.items[1:]
return obj
} | [
"func",
"(",
"q",
"*",
"GenericQueue",
")",
"Deq",
"(",
")",
"Generic",
"{",
"obj",
":=",
"q",
".",
"items",
"[",
"0",
"]",
"\n",
"q",
".",
"items",
"=",
"q",
".",
"items",
"[",
"1",
":",
"]",
"\n",
"return",
"obj",
"\n",
"}"
] | // Deq removes and returns the next item in the queue. | [
"Deq",
"removes",
"and",
"returns",
"the",
"next",
"item",
"in",
"the",
"queue",
"."
] | d2cf3cdd35ce0d789056c4bc02a4d6349c947caf | https://github.com/cheekybits/genny/blob/d2cf3cdd35ce0d789056c4bc02a4d6349c947caf/examples/queue/queue_generic.go#L24-L28 |
28,274 | cheekybits/genny | parse/parse.go | subTypeIntoLine | func subTypeIntoLine(line, typeTemplate, specificType string) string {
src := []byte(line)
var s scanner.Scanner
fset := token.NewFileSet()
file := fset.AddFile("", fset.Base(), len(src))
s.Init(file, src, nil, scanner.ScanComments)
output := ""
for {
_, tok, lit := s.Scan()
if tok == token.EOF {
break
... | go | func subTypeIntoLine(line, typeTemplate, specificType string) string {
src := []byte(line)
var s scanner.Scanner
fset := token.NewFileSet()
file := fset.AddFile("", fset.Base(), len(src))
s.Init(file, src, nil, scanner.ScanComments)
output := ""
for {
_, tok, lit := s.Scan()
if tok == token.EOF {
break
... | [
"func",
"subTypeIntoLine",
"(",
"line",
",",
"typeTemplate",
",",
"specificType",
"string",
")",
"string",
"{",
"src",
":=",
"[",
"]",
"byte",
"(",
"line",
")",
"\n",
"var",
"s",
"scanner",
".",
"Scanner",
"\n",
"fset",
":=",
"token",
".",
"NewFileSet",
... | // Does the heavy lifting of taking a line of our code and
// sbustituting a type into there for our generic type | [
"Does",
"the",
"heavy",
"lifting",
"of",
"taking",
"a",
"line",
"of",
"our",
"code",
"and",
"sbustituting",
"a",
"type",
"into",
"there",
"for",
"our",
"generic",
"type"
] | d2cf3cdd35ce0d789056c4bc02a4d6349c947caf | https://github.com/cheekybits/genny/blob/d2cf3cdd35ce0d789056c4bc02a4d6349c947caf/parse/parse.go#L67-L89 |
28,275 | cheekybits/genny | parse/parse.go | wordify | func wordify(s string, exported bool) string {
s = strings.TrimRight(s, "{}")
s = strings.TrimLeft(s, "*&")
s = strings.Replace(s, ".", "", -1)
if !exported {
return s
}
return strings.ToUpper(string(s[0])) + s[1:]
} | go | func wordify(s string, exported bool) string {
s = strings.TrimRight(s, "{}")
s = strings.TrimLeft(s, "*&")
s = strings.Replace(s, ".", "", -1)
if !exported {
return s
}
return strings.ToUpper(string(s[0])) + s[1:]
} | [
"func",
"wordify",
"(",
"s",
"string",
",",
"exported",
"bool",
")",
"string",
"{",
"s",
"=",
"strings",
".",
"TrimRight",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"s",
"=",
"strings",
".",
"TrimLeft",
"(",
"s",
",",
"\"",
"\"",
")",
"\n",
"s",
"=... | // wordify turns a type into a nice word for function and type
// names etc. | [
"wordify",
"turns",
"a",
"type",
"into",
"a",
"nice",
"word",
"for",
"function",
"and",
"type",
"names",
"etc",
"."
] | d2cf3cdd35ce0d789056c4bc02a4d6349c947caf | https://github.com/cheekybits/genny/blob/d2cf3cdd35ce0d789056c4bc02a4d6349c947caf/parse/parse.go#L263-L271 |
28,276 | cheekybits/genny | out/lazy_file.go | Close | func (lw *LazyFile) Close() error {
if lw.file != nil {
return lw.file.Close()
}
return nil
} | go | func (lw *LazyFile) Close() error {
if lw.file != nil {
return lw.file.Close()
}
return nil
} | [
"func",
"(",
"lw",
"*",
"LazyFile",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"lw",
".",
"file",
"!=",
"nil",
"{",
"return",
"lw",
".",
"file",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Close closes the file if it is created. Returns nil if no file is created. | [
"Close",
"closes",
"the",
"file",
"if",
"it",
"is",
"created",
".",
"Returns",
"nil",
"if",
"no",
"file",
"is",
"created",
"."
] | d2cf3cdd35ce0d789056c4bc02a4d6349c947caf | https://github.com/cheekybits/genny/blob/d2cf3cdd35ce0d789056c4bc02a4d6349c947caf/out/lazy_file.go#L18-L23 |
28,277 | cheekybits/genny | out/lazy_file.go | Write | func (lw *LazyFile) Write(p []byte) (int, error) {
if lw.file == nil {
err := os.MkdirAll(path.Dir(lw.FileName), 0755)
if err != nil {
return 0, err
}
lw.file, err = os.Create(lw.FileName)
if err != nil {
return 0, err
}
}
return lw.file.Write(p)
} | go | func (lw *LazyFile) Write(p []byte) (int, error) {
if lw.file == nil {
err := os.MkdirAll(path.Dir(lw.FileName), 0755)
if err != nil {
return 0, err
}
lw.file, err = os.Create(lw.FileName)
if err != nil {
return 0, err
}
}
return lw.file.Write(p)
} | [
"func",
"(",
"lw",
"*",
"LazyFile",
")",
"Write",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"lw",
".",
"file",
"==",
"nil",
"{",
"err",
":=",
"os",
".",
"MkdirAll",
"(",
"path",
".",
"Dir",
"(",
"lw",
".",
"... | // Write writes to the specified file and creates the file first time it is called. | [
"Write",
"writes",
"to",
"the",
"specified",
"file",
"and",
"creates",
"the",
"file",
"first",
"time",
"it",
"is",
"called",
"."
] | d2cf3cdd35ce0d789056c4bc02a4d6349c947caf | https://github.com/cheekybits/genny/blob/d2cf3cdd35ce0d789056c4bc02a4d6349c947caf/out/lazy_file.go#L26-L38 |
28,278 | cheekybits/genny | main.go | gen | func gen(filename, pkgName string, in io.ReadSeeker, typesets []map[string]string, out io.Writer) error {
var output []byte
var err error
output, err = parse.Generics(filename, pkgName, in, typesets)
if err != nil {
return err
}
out.Write(output)
return nil
} | go | func gen(filename, pkgName string, in io.ReadSeeker, typesets []map[string]string, out io.Writer) error {
var output []byte
var err error
output, err = parse.Generics(filename, pkgName, in, typesets)
if err != nil {
return err
}
out.Write(output)
return nil
} | [
"func",
"gen",
"(",
"filename",
",",
"pkgName",
"string",
",",
"in",
"io",
".",
"ReadSeeker",
",",
"typesets",
"[",
"]",
"map",
"[",
"string",
"]",
"string",
",",
"out",
"io",
".",
"Writer",
")",
"error",
"{",
"var",
"output",
"[",
"]",
"byte",
"\n... | // gen performs the generic generation. | [
"gen",
"performs",
"the",
"generic",
"generation",
"."
] | d2cf3cdd35ce0d789056c4bc02a4d6349c947caf | https://github.com/cheekybits/genny/blob/d2cf3cdd35ce0d789056c4bc02a4d6349c947caf/main.go#L142-L154 |
28,279 | machinebox/graphql | graphql.go | NewClient | func NewClient(endpoint string, opts ...ClientOption) *Client {
c := &Client{
endpoint: endpoint,
Log: func(string) {},
}
for _, optionFunc := range opts {
optionFunc(c)
}
if c.httpClient == nil {
c.httpClient = http.DefaultClient
}
return c
} | go | func NewClient(endpoint string, opts ...ClientOption) *Client {
c := &Client{
endpoint: endpoint,
Log: func(string) {},
}
for _, optionFunc := range opts {
optionFunc(c)
}
if c.httpClient == nil {
c.httpClient = http.DefaultClient
}
return c
} | [
"func",
"NewClient",
"(",
"endpoint",
"string",
",",
"opts",
"...",
"ClientOption",
")",
"*",
"Client",
"{",
"c",
":=",
"&",
"Client",
"{",
"endpoint",
":",
"endpoint",
",",
"Log",
":",
"func",
"(",
"string",
")",
"{",
"}",
",",
"}",
"\n",
"for",
"... | // NewClient makes a new Client capable of making GraphQL requests. | [
"NewClient",
"makes",
"a",
"new",
"Client",
"capable",
"of",
"making",
"GraphQL",
"requests",
"."
] | 3a92531802258604bd12793465c2e28bc4b2fc85 | https://github.com/machinebox/graphql/blob/3a92531802258604bd12793465c2e28bc4b2fc85/graphql.go#L61-L73 |
28,280 | machinebox/graphql | graphql.go | Run | func (c *Client) Run(ctx context.Context, req *Request, resp interface{}) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
if len(req.files) > 0 && !c.useMultipartForm {
return errors.New("cannot send files with PostFields option")
}
if c.useMultipartForm {
return c.runWithPostFields(ctx, re... | go | func (c *Client) Run(ctx context.Context, req *Request, resp interface{}) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
if len(req.files) > 0 && !c.useMultipartForm {
return errors.New("cannot send files with PostFields option")
}
if c.useMultipartForm {
return c.runWithPostFields(ctx, re... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Run",
"(",
"ctx",
"context",
".",
"Context",
",",
"req",
"*",
"Request",
",",
"resp",
"interface",
"{",
"}",
")",
"error",
"{",
"select",
"{",
"case",
"<-",
"ctx",
".",
"Done",
"(",
")",
":",
"return",
"ctx"... | // Run executes the query and unmarshals the response from the data field
// into the response object.
// Pass in a nil response object to skip response parsing.
// If the request fails or the server returns an error, the first error
// will be returned. | [
"Run",
"executes",
"the",
"query",
"and",
"unmarshals",
"the",
"response",
"from",
"the",
"data",
"field",
"into",
"the",
"response",
"object",
".",
"Pass",
"in",
"a",
"nil",
"response",
"object",
"to",
"skip",
"response",
"parsing",
".",
"If",
"the",
"req... | 3a92531802258604bd12793465c2e28bc4b2fc85 | https://github.com/machinebox/graphql/blob/3a92531802258604bd12793465c2e28bc4b2fc85/graphql.go#L84-L97 |
28,281 | machinebox/graphql | graphql.go | NewRequest | func NewRequest(q string) *Request {
req := &Request{
q: q,
Header: make(map[string][]string),
}
return req
} | go | func NewRequest(q string) *Request {
req := &Request{
q: q,
Header: make(map[string][]string),
}
return req
} | [
"func",
"NewRequest",
"(",
"q",
"string",
")",
"*",
"Request",
"{",
"req",
":=",
"&",
"Request",
"{",
"q",
":",
"q",
",",
"Header",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
",",
"}",
"\n",
"return",
"req",
"\n",
"}"... | // NewRequest makes a new Request with the specified string. | [
"NewRequest",
"makes",
"a",
"new",
"Request",
"with",
"the",
"specified",
"string",
"."
] | 3a92531802258604bd12793465c2e28bc4b2fc85 | https://github.com/machinebox/graphql/blob/3a92531802258604bd12793465c2e28bc4b2fc85/graphql.go#L277-L283 |
28,282 | machinebox/graphql | graphql.go | Var | func (req *Request) Var(key string, value interface{}) {
if req.vars == nil {
req.vars = make(map[string]interface{})
}
req.vars[key] = value
} | go | func (req *Request) Var(key string, value interface{}) {
if req.vars == nil {
req.vars = make(map[string]interface{})
}
req.vars[key] = value
} | [
"func",
"(",
"req",
"*",
"Request",
")",
"Var",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"if",
"req",
".",
"vars",
"==",
"nil",
"{",
"req",
".",
"vars",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // Var sets a variable. | [
"Var",
"sets",
"a",
"variable",
"."
] | 3a92531802258604bd12793465c2e28bc4b2fc85 | https://github.com/machinebox/graphql/blob/3a92531802258604bd12793465c2e28bc4b2fc85/graphql.go#L286-L291 |
28,283 | machinebox/graphql | graphql.go | File | func (req *Request) File(fieldname, filename string, r io.Reader) {
req.files = append(req.files, File{
Field: fieldname,
Name: filename,
R: r,
})
} | go | func (req *Request) File(fieldname, filename string, r io.Reader) {
req.files = append(req.files, File{
Field: fieldname,
Name: filename,
R: r,
})
} | [
"func",
"(",
"req",
"*",
"Request",
")",
"File",
"(",
"fieldname",
",",
"filename",
"string",
",",
"r",
"io",
".",
"Reader",
")",
"{",
"req",
".",
"files",
"=",
"append",
"(",
"req",
".",
"files",
",",
"File",
"{",
"Field",
":",
"fieldname",
",",
... | // File sets a file to upload.
// Files are only supported with a Client that was created with
// the UseMultipartForm option. | [
"File",
"sets",
"a",
"file",
"to",
"upload",
".",
"Files",
"are",
"only",
"supported",
"with",
"a",
"Client",
"that",
"was",
"created",
"with",
"the",
"UseMultipartForm",
"option",
"."
] | 3a92531802258604bd12793465c2e28bc4b2fc85 | https://github.com/machinebox/graphql/blob/3a92531802258604bd12793465c2e28bc4b2fc85/graphql.go#L311-L317 |
28,284 | cenkalti/backoff | context.go | WithContext | func WithContext(b BackOff, ctx context.Context) BackOffContext {
if ctx == nil {
panic("nil context")
}
if b, ok := b.(*backOffContext); ok {
return &backOffContext{
BackOff: b.BackOff,
ctx: ctx,
}
}
return &backOffContext{
BackOff: b,
ctx: ctx,
}
} | go | func WithContext(b BackOff, ctx context.Context) BackOffContext {
if ctx == nil {
panic("nil context")
}
if b, ok := b.(*backOffContext); ok {
return &backOffContext{
BackOff: b.BackOff,
ctx: ctx,
}
}
return &backOffContext{
BackOff: b,
ctx: ctx,
}
} | [
"func",
"WithContext",
"(",
"b",
"BackOff",
",",
"ctx",
"context",
".",
"Context",
")",
"BackOffContext",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"if",
"b",
",",
"ok",
":=",
"b",
".",
"(",
"*",
"backO... | // WithContext returns a BackOffContext with context ctx
//
// ctx must not be nil | [
"WithContext",
"returns",
"a",
"BackOffContext",
"with",
"context",
"ctx",
"ctx",
"must",
"not",
"be",
"nil"
] | 1e4cf3da559842a91afcb6ea6141451e6c30c618 | https://github.com/cenkalti/backoff/blob/1e4cf3da559842a91afcb6ea6141451e6c30c618/context.go#L23-L39 |
28,285 | sideshow/apns2 | notification.go | MarshalJSON | func (n *Notification) MarshalJSON() ([]byte, error) {
switch n.Payload.(type) {
case string:
return []byte(n.Payload.(string)), nil
case []byte:
return n.Payload.([]byte), nil
default:
return json.Marshal(n.Payload)
}
} | go | func (n *Notification) MarshalJSON() ([]byte, error) {
switch n.Payload.(type) {
case string:
return []byte(n.Payload.(string)), nil
case []byte:
return n.Payload.([]byte), nil
default:
return json.Marshal(n.Payload)
}
} | [
"func",
"(",
"n",
"*",
"Notification",
")",
"MarshalJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"switch",
"n",
".",
"Payload",
".",
"(",
"type",
")",
"{",
"case",
"string",
":",
"return",
"[",
"]",
"byte",
"(",
"n",
".",
"Pa... | // MarshalJSON converts the notification payload to JSON. | [
"MarshalJSON",
"converts",
"the",
"notification",
"payload",
"to",
"JSON",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/notification.go#L71-L80 |
28,286 | sideshow/apns2 | token/token.go | GenerateIfExpired | func (t *Token) GenerateIfExpired() {
t.Lock()
defer t.Unlock()
if t.Expired() {
t.Generate()
}
} | go | func (t *Token) GenerateIfExpired() {
t.Lock()
defer t.Unlock()
if t.Expired() {
t.Generate()
}
} | [
"func",
"(",
"t",
"*",
"Token",
")",
"GenerateIfExpired",
"(",
")",
"{",
"t",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"Unlock",
"(",
")",
"\n",
"if",
"t",
".",
"Expired",
"(",
")",
"{",
"t",
".",
"Generate",
"(",
")",
"\n",
"}",
"\n",... | // GenerateIfExpired checks to see if the token is about to expire and
// generates a new token. | [
"GenerateIfExpired",
"checks",
"to",
"see",
"if",
"the",
"token",
"is",
"about",
"to",
"expire",
"and",
"generates",
"a",
"new",
"token",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/token/token.go#L71-L77 |
28,287 | sideshow/apns2 | token/token.go | Expired | func (t *Token) Expired() bool {
return time.Now().Unix() >= (t.IssuedAt + TokenTimeout)
} | go | func (t *Token) Expired() bool {
return time.Now().Unix() >= (t.IssuedAt + TokenTimeout)
} | [
"func",
"(",
"t",
"*",
"Token",
")",
"Expired",
"(",
")",
"bool",
"{",
"return",
"time",
".",
"Now",
"(",
")",
".",
"Unix",
"(",
")",
">=",
"(",
"t",
".",
"IssuedAt",
"+",
"TokenTimeout",
")",
"\n",
"}"
] | // Expired checks to see if the token has expired. | [
"Expired",
"checks",
"to",
"see",
"if",
"the",
"token",
"has",
"expired",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/token/token.go#L80-L82 |
28,288 | sideshow/apns2 | token/token.go | Generate | func (t *Token) Generate() (bool, error) {
if t.AuthKey == nil {
return false, ErrAuthKeyNil
}
issuedAt := time.Now().Unix()
jwtToken := &jwt.Token{
Header: map[string]interface{}{
"alg": "ES256",
"kid": t.KeyID,
},
Claims: jwt.MapClaims{
"iss": t.TeamID,
"iat": issuedAt,
},
Method: jwt.Sign... | go | func (t *Token) Generate() (bool, error) {
if t.AuthKey == nil {
return false, ErrAuthKeyNil
}
issuedAt := time.Now().Unix()
jwtToken := &jwt.Token{
Header: map[string]interface{}{
"alg": "ES256",
"kid": t.KeyID,
},
Claims: jwt.MapClaims{
"iss": t.TeamID,
"iat": issuedAt,
},
Method: jwt.Sign... | [
"func",
"(",
"t",
"*",
"Token",
")",
"Generate",
"(",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"t",
".",
"AuthKey",
"==",
"nil",
"{",
"return",
"false",
",",
"ErrAuthKeyNil",
"\n",
"}",
"\n",
"issuedAt",
":=",
"time",
".",
"Now",
"(",
")",... | // Generate creates a new token. | [
"Generate",
"creates",
"a",
"new",
"token",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/token/token.go#L85-L108 |
28,289 | sideshow/apns2 | client.go | Push | func (c *Client) Push(n *Notification) (*Response, error) {
return c.PushWithContext(nil, n)
} | go | func (c *Client) Push(n *Notification) (*Response, error) {
return c.PushWithContext(nil, n)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Push",
"(",
"n",
"*",
"Notification",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"return",
"c",
".",
"PushWithContext",
"(",
"nil",
",",
"n",
")",
"\n",
"}"
] | // Push sends a Notification to the APNs gateway. If the underlying http.Client
// is not currently connected, this method will attempt to reconnect
// transparently before sending the notification. It will return a Response
// indicating whether the notification was accepted or rejected by the APNs
// gateway, or an e... | [
"Push",
"sends",
"a",
"Notification",
"to",
"the",
"APNs",
"gateway",
".",
"If",
"the",
"underlying",
"http",
".",
"Client",
"is",
"not",
"currently",
"connected",
"this",
"method",
"will",
"attempt",
"to",
"reconnect",
"transparently",
"before",
"sending",
"t... | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client.go#L137-L139 |
28,290 | sideshow/apns2 | client.go | PushWithContext | func (c *Client) PushWithContext(ctx Context, n *Notification) (*Response, error) {
payload, err := json.Marshal(n)
if err != nil {
return nil, err
}
url := fmt.Sprintf("%v/3/device/%v", c.Host, n.DeviceToken)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
if c.Token != nil {
c.setTokenHea... | go | func (c *Client) PushWithContext(ctx Context, n *Notification) (*Response, error) {
payload, err := json.Marshal(n)
if err != nil {
return nil, err
}
url := fmt.Sprintf("%v/3/device/%v", c.Host, n.DeviceToken)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payload))
if c.Token != nil {
c.setTokenHea... | [
"func",
"(",
"c",
"*",
"Client",
")",
"PushWithContext",
"(",
"ctx",
"Context",
",",
"n",
"*",
"Notification",
")",
"(",
"*",
"Response",
",",
"error",
")",
"{",
"payload",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"n",
")",
"\n",
"if",
"err",... | // PushWithContext sends a Notification to the APNs gateway. Context carries a
// deadline and a cancellation signal and allows you to close long running
// requests when the context timeout is exceeded. Context can be nil, for
// backwards compatibility.
//
// If the underlying http.Client is not currently connected, ... | [
"PushWithContext",
"sends",
"a",
"Notification",
"to",
"the",
"APNs",
"gateway",
".",
"Context",
"carries",
"a",
"deadline",
"and",
"a",
"cancellation",
"signal",
"and",
"allows",
"you",
"to",
"close",
"long",
"running",
"requests",
"when",
"the",
"context",
"... | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client.go#L150-L180 |
28,291 | sideshow/apns2 | client_manager.go | NewClientManager | func NewClientManager() *ClientManager {
manager := &ClientManager{
MaxSize: 64,
MaxAge: 10 * time.Minute,
Factory: NewClient,
}
manager.initInternals()
return manager
} | go | func NewClientManager() *ClientManager {
manager := &ClientManager{
MaxSize: 64,
MaxAge: 10 * time.Minute,
Factory: NewClient,
}
manager.initInternals()
return manager
} | [
"func",
"NewClientManager",
"(",
")",
"*",
"ClientManager",
"{",
"manager",
":=",
"&",
"ClientManager",
"{",
"MaxSize",
":",
"64",
",",
"MaxAge",
":",
"10",
"*",
"time",
".",
"Minute",
",",
"Factory",
":",
"NewClient",
",",
"}",
"\n\n",
"manager",
".",
... | // NewClientManager returns a new ClientManager for prolonged, concurrent usage
// of multiple APNs clients. ClientManager is flexible enough to work best for
// your use case. When a client is not found in the manager, Get will return
// the result of calling Factory, which can be a Client or nil.
//
// Having multipl... | [
"NewClientManager",
"returns",
"a",
"new",
"ClientManager",
"for",
"prolonged",
"concurrent",
"usage",
"of",
"multiple",
"APNs",
"clients",
".",
"ClientManager",
"is",
"flexible",
"enough",
"to",
"work",
"best",
"for",
"your",
"use",
"case",
".",
"When",
"a",
... | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client_manager.go#L49-L59 |
28,292 | sideshow/apns2 | client_manager.go | Add | func (m *ClientManager) Add(client *Client) {
m.initInternals()
m.mu.Lock()
defer m.mu.Unlock()
key := cacheKey(client.Certificate)
now := time.Now()
if ele, hit := m.cache[key]; hit {
item := ele.Value.(*managerItem)
item.client = client
item.lastUsed = now
m.ll.MoveToFront(ele)
return
}
ele := m.ll... | go | func (m *ClientManager) Add(client *Client) {
m.initInternals()
m.mu.Lock()
defer m.mu.Unlock()
key := cacheKey(client.Certificate)
now := time.Now()
if ele, hit := m.cache[key]; hit {
item := ele.Value.(*managerItem)
item.client = client
item.lastUsed = now
m.ll.MoveToFront(ele)
return
}
ele := m.ll... | [
"func",
"(",
"m",
"*",
"ClientManager",
")",
"Add",
"(",
"client",
"*",
"Client",
")",
"{",
"m",
".",
"initInternals",
"(",
")",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"key",... | // Add adds a Client to the manager. You can use this to individually configure
// Clients in the manager. | [
"Add",
"adds",
"a",
"Client",
"to",
"the",
"manager",
".",
"You",
"can",
"use",
"this",
"to",
"individually",
"configure",
"Clients",
"in",
"the",
"manager",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client_manager.go#L63-L84 |
28,293 | sideshow/apns2 | client_manager.go | Get | func (m *ClientManager) Get(certificate tls.Certificate) *Client {
m.initInternals()
m.mu.Lock()
defer m.mu.Unlock()
key := cacheKey(certificate)
now := time.Now()
if ele, hit := m.cache[key]; hit {
item := ele.Value.(*managerItem)
if m.MaxAge != 0 && item.lastUsed.Before(now.Add(-m.MaxAge)) {
c := m.Fact... | go | func (m *ClientManager) Get(certificate tls.Certificate) *Client {
m.initInternals()
m.mu.Lock()
defer m.mu.Unlock()
key := cacheKey(certificate)
now := time.Now()
if ele, hit := m.cache[key]; hit {
item := ele.Value.(*managerItem)
if m.MaxAge != 0 && item.lastUsed.Before(now.Add(-m.MaxAge)) {
c := m.Fact... | [
"func",
"(",
"m",
"*",
"ClientManager",
")",
"Get",
"(",
"certificate",
"tls",
".",
"Certificate",
")",
"*",
"Client",
"{",
"m",
".",
"initInternals",
"(",
")",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unl... | // Get gets a Client from the manager. If a Client is not found in the manager
// or if a Client has remained in the manager longer than MaxAge, Get will call
// the ClientManager's Factory function, store the result in the manager if
// non-nil, and return it. | [
"Get",
"gets",
"a",
"Client",
"from",
"the",
"manager",
".",
"If",
"a",
"Client",
"is",
"not",
"found",
"in",
"the",
"manager",
"or",
"if",
"a",
"Client",
"has",
"remained",
"in",
"the",
"manager",
"longer",
"than",
"MaxAge",
"Get",
"will",
"call",
"th... | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client_manager.go#L90-L119 |
28,294 | sideshow/apns2 | client_manager.go | Len | func (m *ClientManager) Len() int {
if m.cache == nil {
return 0
}
m.mu.Lock()
defer m.mu.Unlock()
return m.ll.Len()
} | go | func (m *ClientManager) Len() int {
if m.cache == nil {
return 0
}
m.mu.Lock()
defer m.mu.Unlock()
return m.ll.Len()
} | [
"func",
"(",
"m",
"*",
"ClientManager",
")",
"Len",
"(",
")",
"int",
"{",
"if",
"m",
".",
"cache",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"m",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"m",
".",
"mu",
".",
"Unlock",
"(",
"... | // Len returns the current size of the ClientManager. | [
"Len",
"returns",
"the",
"current",
"size",
"of",
"the",
"ClientManager",
"."
] | d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2 | https://github.com/sideshow/apns2/blob/d5157a5e6ef01fe1b953450a7a8a1bbe77e865c2/client_manager.go#L122-L129 |
28,295 | google/zoekt | gitindex/submodule.go | ParseGitModules | func ParseGitModules(content []byte) (map[string]*SubmoduleEntry, error) {
dec := config.NewDecoder(bytes.NewBuffer(content))
cfg := &config.Config{}
if err := dec.Decode(cfg); err != nil {
return nil, err
}
result := map[string]*SubmoduleEntry{}
for _, s := range cfg.Sections {
if s.Name != "submodule" {
... | go | func ParseGitModules(content []byte) (map[string]*SubmoduleEntry, error) {
dec := config.NewDecoder(bytes.NewBuffer(content))
cfg := &config.Config{}
if err := dec.Decode(cfg); err != nil {
return nil, err
}
result := map[string]*SubmoduleEntry{}
for _, s := range cfg.Sections {
if s.Name != "submodule" {
... | [
"func",
"ParseGitModules",
"(",
"content",
"[",
"]",
"byte",
")",
"(",
"map",
"[",
"string",
"]",
"*",
"SubmoduleEntry",
",",
"error",
")",
"{",
"dec",
":=",
"config",
".",
"NewDecoder",
"(",
"bytes",
".",
"NewBuffer",
"(",
"content",
")",
")",
"\n",
... | // ParseGitModules parses the contents of a .gitmodules file. | [
"ParseGitModules",
"parses",
"the",
"contents",
"of",
"a",
".",
"gitmodules",
"file",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/gitindex/submodule.go#L31-L64 |
28,296 | google/zoekt | bits.go | caseFoldingEqualsRunes | func caseFoldingEqualsRunes(lower, mixed []byte) (int, bool) {
matchTotal := 0
for len(lower) > 0 && len(mixed) > 0 {
lr, lsz := utf8.DecodeRune(lower)
lower = lower[lsz:]
mr, msz := utf8.DecodeRune(mixed)
mixed = mixed[msz:]
matchTotal += msz
if lr != unicode.ToLower(mr) {
return 0, false
}
}
r... | go | func caseFoldingEqualsRunes(lower, mixed []byte) (int, bool) {
matchTotal := 0
for len(lower) > 0 && len(mixed) > 0 {
lr, lsz := utf8.DecodeRune(lower)
lower = lower[lsz:]
mr, msz := utf8.DecodeRune(mixed)
mixed = mixed[msz:]
matchTotal += msz
if lr != unicode.ToLower(mr) {
return 0, false
}
}
r... | [
"func",
"caseFoldingEqualsRunes",
"(",
"lower",
",",
"mixed",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"bool",
")",
"{",
"matchTotal",
":=",
"0",
"\n",
"for",
"len",
"(",
"lower",
")",
">",
"0",
"&&",
"len",
"(",
"mixed",
")",
">",
"0",
"{",
"lr",... | // compare 'lower' and 'mixed', where lower is the needle. 'mixed' may
// be larger than 'lower'. Returns whether there was a match, and if
// yes, the byte size of the match. | [
"compare",
"lower",
"and",
"mixed",
"where",
"lower",
"is",
"the",
"needle",
".",
"mixed",
"may",
"be",
"larger",
"than",
"lower",
".",
"Returns",
"whether",
"there",
"was",
"a",
"match",
"and",
"if",
"yes",
"the",
"byte",
"size",
"of",
"the",
"match",
... | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/bits.go#L59-L75 |
28,297 | google/zoekt | query/parse.go | parseStringLiteral | func parseStringLiteral(in []byte) (lit []byte, n int, err error) {
left := in[1:]
found := false
loop:
for len(left) > 0 {
c := left[0]
left = left[1:]
switch c {
case '"':
found = true
break loop
case '\\':
// TODO - other escape sequences.
if len(left) == 0 {
return nil, 0, fmt.Errorf("... | go | func parseStringLiteral(in []byte) (lit []byte, n int, err error) {
left := in[1:]
found := false
loop:
for len(left) > 0 {
c := left[0]
left = left[1:]
switch c {
case '"':
found = true
break loop
case '\\':
// TODO - other escape sequences.
if len(left) == 0 {
return nil, 0, fmt.Errorf("... | [
"func",
"parseStringLiteral",
"(",
"in",
"[",
"]",
"byte",
")",
"(",
"lit",
"[",
"]",
"byte",
",",
"n",
"int",
",",
"err",
"error",
")",
"{",
"left",
":=",
"in",
"[",
"1",
":",
"]",
"\n",
"found",
":=",
"false",
"\n\n",
"loop",
":",
"for",
"len... | // parseStringLiteral parses a string literal, consumes the starting
// quote too. | [
"parseStringLiteral",
"parses",
"a",
"string",
"literal",
"consumes",
"the",
"starting",
"quote",
"too",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L37-L66 |
28,298 | google/zoekt | query/parse.go | Parse | func Parse(qStr string) (Q, error) {
b := []byte(qStr)
qs, _, err := parseExprList(b)
if err != nil {
return nil, err
}
q, err := parseOperators(qs)
if err != nil {
return nil, err
}
return Simplify(q), nil
} | go | func Parse(qStr string) (Q, error) {
b := []byte(qStr)
qs, _, err := parseExprList(b)
if err != nil {
return nil, err
}
q, err := parseOperators(qs)
if err != nil {
return nil, err
}
return Simplify(q), nil
} | [
"func",
"Parse",
"(",
"qStr",
"string",
")",
"(",
"Q",
",",
"error",
")",
"{",
"b",
":=",
"[",
"]",
"byte",
"(",
"qStr",
")",
"\n\n",
"qs",
",",
"_",
",",
"err",
":=",
"parseExprList",
"(",
"b",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // Parse parses a string into a query. | [
"Parse",
"parses",
"a",
"string",
"into",
"a",
"query",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L81-L95 |
28,299 | google/zoekt | query/parse.go | regexpQuery | func regexpQuery(text string, content, file bool) (Q, error) {
var expr Q
r, err := syntax.Parse(text, syntax.ClassNL|syntax.PerlX|syntax.UnicodeGroups)
if err != nil {
return nil, err
}
if r.Op == syntax.OpLiteral {
expr = &Substring{
Pattern: string(r.Rune),
FileName: file,
Content: content,
}... | go | func regexpQuery(text string, content, file bool) (Q, error) {
var expr Q
r, err := syntax.Parse(text, syntax.ClassNL|syntax.PerlX|syntax.UnicodeGroups)
if err != nil {
return nil, err
}
if r.Op == syntax.OpLiteral {
expr = &Substring{
Pattern: string(r.Rune),
FileName: file,
Content: content,
}... | [
"func",
"regexpQuery",
"(",
"text",
"string",
",",
"content",
",",
"file",
"bool",
")",
"(",
"Q",
",",
"error",
")",
"{",
"var",
"expr",
"Q",
"\n\n",
"r",
",",
"err",
":=",
"syntax",
".",
"Parse",
"(",
"text",
",",
"syntax",
".",
"ClassNL",
"|",
... | // regexpQuery parses an atom into either a regular expression, or a
// simple substring atom. | [
"regexpQuery",
"parses",
"an",
"atom",
"into",
"either",
"a",
"regular",
"expression",
"or",
"a",
"simple",
"substring",
"atom",
"."
] | 3493be98f11f3ca46cdb973a968f09f7cacc645d | https://github.com/google/zoekt/blob/3493be98f11f3ca46cdb973a968f09f7cacc645d/query/parse.go#L197-L220 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.