-
Notifications
You must be signed in to change notification settings - Fork 575
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split up fixers into the two remaining bits
- Loading branch information
Showing
14 changed files
with
312 additions
and
283 deletions.
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
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
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
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,35 @@ | ||
from __future__ import division, print_function, absolute_import, \ | ||
unicode_literals | ||
|
||
|
||
class IdKey(object): | ||
|
||
def __init__(self, value): | ||
self.value = value | ||
|
||
def __eq__(self, other): | ||
return (type(other) == IdKey) and (self.value is other.value) | ||
|
||
def __ne__(self, other): | ||
return not (self.__eq__(other)) | ||
|
||
def __hash__(self): | ||
return hash(id(self.value)) | ||
|
||
|
||
class IdentitySet(object): | ||
|
||
def __init__(self): | ||
self.data = {} | ||
|
||
def __contains__(self, value): | ||
key = IdKey(value) | ||
return self.data.get(key, 0) > 0 | ||
|
||
def add(self, value): | ||
key = IdKey(value) | ||
self.data[key] = self.data.get(key, 0) + 1 | ||
|
||
def remove(self, value): | ||
key = IdKey(value) | ||
self.data[key] = self.data.get(key, 0) - 1 |
Oops, something went wrong.