Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

M. Fürstenau mfuerstenau

🏠
Working from home
  • Germany/Deutschland, Duisburg, Essen, Gelsenkirchen
View GitHub Profile
@mfuerstenau
mfuerstenau / StreamAsIterable.java
Last active Aug 21, 2016
Streams can be iterated over in Java 8
View StreamAsIterable.java
public class StreamAsIterable
{
public static void main (String[] args)
{
for (String s : (Iterable<String>) Stream.of ("This", "is", "a", "stream")::iterator)
{
System.out.println (s);
}
}
}
@mfuerstenau
mfuerstenau / zigzag-encoding.README
Last active May 23, 2021
ZigZag encoding/decoding explained
View zigzag-encoding.README
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation