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
@Test | |
public void testJoiner() throws Exception { | |
List<String> texts = Lists.newArrayList("eins", null, "drei", "vier", "fünf", "sechs", "sieben", null); | |
String joined; | |
String expected; | |
joined = Joiner.on(";") | |
.skipNulls() | |
.join(texts); |
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
final String stringToSplit = "dave:123, john:314,, matt:989"; | |
final Map<String, String> splitKeyValues = Splitter.on(",") | |
.omitEmptyStrings() | |
.trimResults() | |
.withKeyValueSeparator(":") | |
.split(stringToSplit); | |
// Map Contents: {dave=123, john=314, matt=989} |
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
# Compiled source # | |
################### | |
*.com | |
*.class | |
*.dll | |
*.exe | |
*.o | |
*.so | |
# Packages # |
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
/* | |
* adapted from example @ http://stackoverflow.com/questions/2723397/what-is-pecs-producer-extends-consumer-super/2723538#2723538 | |
* Get And Put Principle (From Java Generics and Collections) | |
* | |
* It states, | |
* use an extends wildcard when you only get values out of a structure | |
* use a super wildcard when you only put values into a structure | |
* **** and don’t use a wildcard when you both get and put. *** | |
* | |
*/ |
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
/* | |
* Licensed to the Apache Software Foundation (ASF) under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. The ASF licenses this file | |
* to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
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
/* | |
RadixSort.java : Sorts 32-bit integers with O(n*k) runtime performance. | |
Where k is the max number of digits of the numbers being | |
sorted. | |
(i.e. k=10 digits for 32-bit integers.) | |
Copyright (C) 2013 Yeison Rodriguez ( github.com/yeison ) | |
This program is free software; you can redistribute it and/or | |
modify it under the terms of the GNU General Public License |
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
package counting.sort; | |
public class CountingSort | |
{ | |
public static int maximumElement( Integer array[] ) | |
{ | |
// Set the largest element to the first for comparison | |
int max; | |
max = array[ 1 ]; |
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 BinarySearch { | |
// Find first target in array | |
public int binarySearch(int[] arr, int target){ | |
if (arr.length == 0){ | |
return -1; | |
} | |
int start = 0 ; | |
int end = arr.length - 1; | |
int mid; |
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
var binary_search = function (list, item) { | |
var low = 0; | |
var high = list.length - 1; | |
while(low <= high) { | |
var mid = Math.floor((low + high) / 2); | |
var guess = list[mid]; | |
if (guess === item) { | |
return mid; | |
} else if (guess > item) { | |
high = mid - 1; |
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
function nextLex(str) { | |
var breakIndex = -1; | |
var chars = str.split(""); | |
for (var i=chars.length-1; i>0; i--) { | |
if (chars[i] > chars[i-1]) { | |
breakIndex = i-1; | |
break; | |
} | |
} |