- [Data Structures] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#data-structures)
- [Linked Lists] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#linked-lists)
- [Trees] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#trees)
- [Binary Trees] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#binary-trees)
- [Binary Search Tree] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#binary-search-tree)
- [Red-Black Tree] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#red-black-tree)
- [AVL Tree] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#avl-tree)
- [Tries] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#tries)
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
/** | |
* @param interval The base interval to start backing off from. The function is: attemptNum^2 * intervalTime | |
* @param units The units for interval | |
* @param retryAttempts The max number of attempts to retry this task or -1 to try MAX_INT times, | |
*/ | |
public static <T> Observable.Transformer<T, T> backoff(final long interval, final TimeUnit units, final int retryAttempts) { | |
return new Observable.Transformer<T, T>() { | |
@Override | |
public Observable<T> call(final Observable<T> observable) { | |
return observable.retryWhen( |
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
// retries up to 3 times while exponentially backing off with each retry | |
.retryWhen(errors -> | |
errors | |
.zipWith( | |
Observable.range(1, MAX_RETRIES), (n, i) -> i | |
) | |
.flatMap( | |
retryCount -> Observable.timer((long) Math.pow(4, retryCount), TimeUnit.SECONDS) | |
) | |
) |
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
public void readTwice() | |
{ | |
Observable.fromCallable(() -> { | |
RedditData inflatedModel = null; | |
Response response = makeRequest(); | |
String diskValue = null; | |
try { | |
File file = new File(getContext().getCacheDir(), "file"); | |
BufferedSink cacheBody = Okio.buffer(Okio.sink(file)); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
about | |
account | |
add | |
admin | |
api | |
app | |
apps | |
archive | |
archives | |
auth |
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
apply plugin: 'java' | |
apply plugin: 'maven-publish' | |
group = 'com.demo' | |
version = '1.0.0' | |
sourceCompatibility = 1.7 | |
repositories { | |
mavenCentral() |