This repository has been archived by the owner on Apr 26, 2019. It is now read-only.
{search,traverse}: clean up after recent changes #44
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d526855
{search,traverse}: remove duplicated test graphs where possible
kortschak 8870d1f
{internal,search,traverse}: new package
kortschak acfbc71
{internal,search}: remove ByComponentLengthOrStart
kortschak e9a2e7c
search: reconcile with johnson function
kortschak 250118f
internal: fix doc comments
kortschak File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright ©2015 The gonum Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package internal | ||
|
||
// A set is a set of integer identifiers. | ||
type IntSet map[int]struct{} | ||
|
||
// The simple accessor methods for Set are provided to allow ease of | ||
// implementation change should the need arise. | ||
|
||
// add inserts an element into the set. | ||
func (s IntSet) Add(e int) { | ||
s[e] = struct{}{} | ||
} | ||
|
||
// has reports the existence of the element in the set. | ||
func (s IntSet) Has(e int) bool { | ||
_, ok := s[e] | ||
return ok | ||
} | ||
|
||
// remove deletes the specified element from the set. | ||
func (s IntSet) Remove(e int) { | ||
delete(s, e) | ||
} | ||
|
||
// count reports the number of elements stored in the set. | ||
func (s IntSet) Count() int { | ||
return len(s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright ©2015 The gonum Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package internal | ||
|
||
// BySliceValues implements the sort.Interface sorting a slice of | ||
// []int lexically by the values of the []int. | ||
type BySliceValues [][]int | ||
|
||
func (c BySliceValues) Len() int { return len(c) } | ||
func (c BySliceValues) Less(i, j int) bool { | ||
a, b := c[i], c[j] | ||
l := len(a) | ||
if len(b) < l { | ||
l = len(b) | ||
} | ||
for k, v := range a[:l] { | ||
if v < b[k] { | ||
return true | ||
} | ||
if v > b[k] { | ||
return false | ||
} | ||
} | ||
return len(a) < len(b) | ||
} | ||
func (c BySliceValues) Swap(i, j int) { c[i], c[j] = c[j], c[i] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A set -> IntSet
And capital letters in the comments below.