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
// We can use stl container list as a double | |
// ended queue to store the cache keys, with | |
// the descending time of reference from front | |
// to back and a set container to check presence | |
// of a key. But to fetch the address of the key | |
// in the list using find(), it takes O(N) time. | |
// This can be optimized by storing a reference | |
// (iterator) to each key in a hash map. | |
#include <bits/stdc++.h> | |
using namespace std; |
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
Below are the Big O performance of common functions of different Java Collections. | |
List | Add | Remove | Get | Contains | Next | Data Structure | |
---------------------|------|--------|------|----------|------|--------------- | |
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array | |
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List | |
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array | |
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 class Version implements Comparable<Version> { | |
@NonNull | |
public final int[] numbers; | |
public Version(@NonNull String version) { | |
final String split[] = version.split("\\-")[0].split("\\."); | |
numbers = new int[split.length]; | |
for (int i = 0; i < split.length; i++) { | |
numbers[i] = Integer.valueOf(split[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
#!groovy | |
import groovy.json.JsonOutput | |
import groovy.json.JsonSlurper | |
/* | |
Please make sure to add the following environment variables: | |
HEROKU_PREVIEW=<your heroku preview app> | |
HEROKU_PREPRODUCTION=<your heroku pre-production app> | |
HEROKU_PRODUCTION=<your heroku production app> |
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
node { | |
echo "=======================================" | |
echo "JENKINS_HOME = ${env.JENKINS_HOME}" | |
echo "JOB_NAME = ${env.JOB_NAME}" | |
echo "REPO_GIT = " + REPO_GIT | |
echo "DEFAULT_GIT_BRANCH = "+ DEFAULT_GIT_BRANCH | |
echo "SONAR_SERVER = "+ SONAR_SERVER | |
echo "=======================================" | |
def sonarInstance=hudson.plugins.sonar.SonarInstallation.get(SONAR_SERVER).name; |