This file contains hidden or 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
trait LoggedAsyncInput[T] | |
{ | |
override def onReceive(acceptor: T => ()) = | |
super.onReceive(x => { println(s“received:${x}”) | |
acceptor(x) }) | |
} |
This file contains hidden or 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
trait AsyncInput[T] | |
{ | |
def onReceive(acceptor: T=>()): Unit | |
def read: Future[T] = { | |
Promise p = Promise[T]() | |
onReceive(p.complete(_)) | |
p.future | |
} |
This file contains hidden or 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
interface AsyncInput<T> | |
{ | |
void onReceive(Acceptor<T> acceptor) | |
default void read(): Future<T> { | |
final CompletableFuture<T> promise = new CompletableFuture<>(); | |
onReceive( x -> promise.complete(x) ); | |
return promise; | |
} | |
This file contains hidden or 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 (maxFirstLen, maxSecondLen) = (0,0) | |
list.foreach{ | |
x => maxFirstLen = max(maxFirstLen, x.firstName.length) | |
maxSecondLen = max(maxSecondLen, x.secondName.lenght) | |
} |
This file contains hidden or 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
list.sort((x,y) => { | |
val cmp = x.lastName.compareTo(y.lastName) | |
if (cmp!=0) cmp else x.firstName.compareTo(y.lastName) | |
} |
This file contains hidden or 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
list.sort((x,y)-> { | |
int cmp = x.lastName.compareTo(y.lastName); | |
return cmp!=0 ? cmp : x.firstName.compareTo(y.firstName) | |
} |
This file contains hidden or 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 Person extends DTOBase | |
{ | |
public String firstName; | |
public String lastName; | |
} |
This file contains hidden or 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 Person | |
{ | |
private String firstName; | |
private String lastName; | |
String getFirstName() { return firstName; } | |
void setFirstName(String firstName) { this.firstName = firstName; } | |
String getLastName() { return lastName; } | |
void setLastName(String lastName) { this.lastName = lastName; } |
This file contains hidden or 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
case class Person(firstName:String, lastName:String) |
This file contains hidden or 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 x | |
import akka.actor._ | |
import scala.concurrent._ | |
import scala.concurrent.duration._ | |
import ExecutionContext.Implicits.global | |
object X | |
{ |