-
Notifications
You must be signed in to change notification settings - Fork 244
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
making changes to reduce size of giant interval lists #1309
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,13 +82,19 @@ public void addLhs(final T object, final Locatable interval) { | |
final int start = interval.getStart() + this.lhsBuffer; | ||
final int end = interval.getEnd() - this.lhsBuffer; | ||
|
||
final Set<T> objects = new HashSet<>(1); | ||
objects.add(object); | ||
final Set<T> newValue = Collections.singleton(object); | ||
if (start <= end) { // Don't put in sequences that have no overlappable bases | ||
final Set<T> alreadyThere = tree.put(start, end, objects); | ||
final Set<T> alreadyThere = tree.put(start, end, newValue); | ||
if (alreadyThere != null) { | ||
alreadyThere.add(object); | ||
tree.put(start, end, alreadyThere); | ||
if( alreadyThere.size() == 1){ | ||
Set<T> mutableSet = new HashSet<>(2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmmm. better find out if you got a mutable one and just add the new element if so...no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean with an instanceof check? As it's written it should be immutable always if it's exactly size 1 and mutable otherwise. It's a bit awkward but I thought maybe relying on the size was better than relying on the class. I can change that though. |
||
mutableSet.addAll(alreadyThere); | ||
mutableSet.add(object); | ||
tree.put(start, end, mutableSet); | ||
} else { | ||
alreadyThere.add(object); | ||
tree.put(start, end, alreadyThere); | ||
} | ||
} | ||
} | ||
} | ||
|
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.
I think that this should be implemented within the IntervalTree class as a
computeIfPresent
method...