Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graph/simple: factor ID handling out of graph types #30

Merged
merged 1 commit into from
May 31, 2017
Merged

Conversation

kortschak
Copy link
Member

This is preparation for adding ID() int to the graph.Edge interface.

@vladimir-ch Please take a look.

@@ -43,3 +45,37 @@ const maxInt int = int(^uint(0) >> 1)
func isSame(a, b float64) bool {
return a == b || (math.IsNaN(a) && math.IsNaN(b))
}

// idset implements available ID storage.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idSet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// newID returns a new unique ID.
func (s *idSet) newID() int {
var id int
if s.free.Len() != 0 && s.free.TakeMin(&id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to just if s.free.TakeMin(&id) { but on the other hand it is less explicit.

Copy link
Member Author

@kortschak kortschak May 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is residual from when the behaviour was map-based. I've made the change, but it looks like we may end up back at the map-based approach anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants