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
class CycleIterator[B <: A, +A](elements: Iterable[B]) extends Iterator[A] { | |
var iterator: Iterator[B] = Iterator.empty | |
def hasNext: Boolean = { | |
if (!iterator.hasNext) { | |
iterator = elements.iterator | |
} | |
iterator.hasNext | |
} |
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
import static com.google.common.base.Preconditions.checkNotNull; | |
import static com.google.common.collect.Iterables.filter; | |
import static com.google.common.collect.Iterators.cycle; | |
import static java.util.Arrays.asList; | |
import java.util.Iterator; | |
import com.google.common.base.Function; | |
import com.google.common.base.Predicate; | |
import com.google.common.collect.FluentIterable; |
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
class FizzBuzz(divisors = Map(3->"Fizz", 5->"Buzz")) { | |
def fizzBuzz(n: Int): String = { | |
divisors.foldLeft(""){(res, d)=> | |
n % d._1 match { | |
case 0 => res + d._2 | |
case _ => res | |
} | |
} match { | |
case "" => n.toString |
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 org.filippodeluca.gwt.examples.contacts; | |
import com.google.gwt.user.client.rpc.IsSerializable; | |
public class Contact implements IsSerializable { | |
private String name; | |
private String email; | |
public Contact(String name, String email) { |
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 | |
* |
NewerOlder