-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from lisa-analyzer/interval-methods
Add auxiliar interval methods
- Loading branch information
Showing
6 changed files
with
198 additions
and
1 deletion.
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
19 changes: 19 additions & 0 deletions
19
lisa/lisa-sdk/src/main/java/it/unive/lisa/util/numeric/InfiniteIterationException.java
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,19 @@ | ||
package it.unive.lisa.util.numeric; | ||
|
||
/** | ||
* An exception throw when someone tries to iterate over a non-finite | ||
* {@link IntInterval}. | ||
* | ||
* @author <a href="mailto:vincenzo.arceri@unipr.it">Vincenzo Arceri</a> | ||
*/ | ||
public class InfiniteIterationException extends RuntimeException { | ||
|
||
/** | ||
* Builds the exception. | ||
* | ||
* @param i the non-finite interval on which some iterates | ||
*/ | ||
public InfiniteIterationException(IntInterval i) { | ||
super("Cannot iterate over the interval " + 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
35 changes: 35 additions & 0 deletions
35
lisa/lisa-sdk/src/main/java/it/unive/lisa/util/numeric/IntIntervalIterator.java
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 @@ | ||
package it.unive.lisa.util.numeric; | ||
|
||
import java.util.Iterator; | ||
|
||
/** | ||
* The {@link IntInterval} iterator. | ||
* | ||
* @author <a href="mailto:vincenzo.arceri@unipr.it">Vincenzo Arceri</a> | ||
*/ | ||
public class IntIntervalIterator implements Iterator<Long> { | ||
|
||
private long init; | ||
private final long end; | ||
|
||
/** | ||
* Builds the iterator. | ||
* | ||
* @param init low bound | ||
* @param end high bound | ||
*/ | ||
public IntIntervalIterator(long init, long end) { | ||
this.init = init; | ||
this.end = end; | ||
} | ||
|
||
@Override | ||
public boolean hasNext() { | ||
return init <= end; | ||
} | ||
|
||
@Override | ||
public Long next() { | ||
return init++; | ||
} | ||
} |
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
19 changes: 19 additions & 0 deletions
19
lisa/lisa-sdk/src/main/java/it/unive/lisa/util/numeric/MathNumberConversionException.java
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,19 @@ | ||
package it.unive.lisa.util.numeric; | ||
|
||
/** | ||
* An exception thrown when a {@link MathNumber} fails to be converted to a | ||
* specific Java numerical type. | ||
* | ||
* @author <a href="mailto:vincenzo.arceri@unipr.it">Vincenzo Arceri</a> | ||
*/ | ||
public class MathNumberConversionException extends Exception { | ||
|
||
/** | ||
* Builds the exception. | ||
* | ||
* @param m the math number that fails to be converted | ||
*/ | ||
public MathNumberConversionException(MathNumber m) { | ||
super("Cannot convert " + m + " to numerical value"); | ||
} | ||
} |