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 ch15; | |
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.io.PrintWriter; | |
import java.net.InetSocketAddress; | |
import java.nio.channels.Channels; | |
import java.nio.channels.ServerSocketChannel; | |
import java.nio.channels.SocketChannel; | |
import java.util.ArrayList; |
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 ch15; | |
import org.junit.jupiter.api.Assertions; | |
import org.junit.jupiter.api.Test; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.PrintWriter; | |
import java.net.Socket; |
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 ch15; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.PrintWriter; |
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 ch15; | |
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import java.io.IOException; | |
import java.net.InetSocketAddress; | |
import java.nio.ByteBuffer; | |
import java.nio.CharBuffer; |
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
List.of(manager1, manager2).stream() | |
.flatMap(m -> | |
Stream.concat(m.getEmployeeList().stream(), Stream.of(m))) | |
.distinct() | |
.mapToInt(Employee::getYearlySalary) | |
.sum(); |
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
@RestController | |
class RestController(val priceService: PriceService) { | |
fun prices(@PathVariable symbol: String): Flux<StockPrice> { | |
} | |
} |
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 com.mechanitis.demo.stockservice | |
import org.springframework.boot.autoconfigure.SpringBootApplication | |
import org.springframework.boot.runApplication | |
@SpringBootApplication | |
class StockServiceApplication | |
fun main(args: Array<String>) { | |
runApplication<StockServiceApplication>(*args) |
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 static class CityAndPhone { | |
private String city; | |
private String phone; | |
public CityAndPhone(String city, String phone) { | |
this.city = city; | |
this.phone = phone; | |
} |
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
static int[][] computeLevenshtein(List<String> wordList, boolean parallel) { | |
final int LIST_SIZE = wordList.size(); | |
int[][] distances = new int[LIST_SIZE][LIST_SIZE]; | |
IntStream stream = IntStream.range(0, LIST_SIZE); | |
if (parallel) { | |
stream = stream.parallel(); // Convert the stream to a parallel one | |
} | |
stream.forEach(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
static int[][] computeLevenshtein(List<String> wordList, boolean parallel) { | |
final int LIST_SIZE = wordList.size(); | |
int[][] distances = new int[LIST_SIZE][LIST_SIZE]; | |
Supplier<Stream<String>> streamSupplier = () -> wordList.stream(); | |
Stream<String> stream = streamSupplier.get(); | |
if (true == parallel) { | |
stream = stream.parallel(); | |
} |
NewerOlder