BAEL-2797 new domain "math"created, sections moved

This commit is contained in:
anilkivilcim.eray
2019-04-03 00:37:24 +03:00
parent 0a8d9fe187
commit 94bf17615c
184 changed files with 717 additions and 218 deletions

View File

@@ -1,21 +0,0 @@
package com.baeldung.algorithms.linesintersection;
import java.awt.Point;
import java.util.Optional;
public class LinesIntersectionService {
public Optional<Point> calculateIntersectionPoint(double m1, double b1, double m2, double b2) {
if (m1 == m2) {
return Optional.empty();
}
double x = (b2 - b1) / (m1 - m2);
double y = m1 * x + b1;
Point point = new Point();
point.setLocation(x, y);
return Optional.of(point);
}
}

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.automata;
package com.baeldung.math.automata;
/**
* Finite state machine.

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.automata;
package com.baeldung.math.automata;
/**
* Default implementation of a finite state machine.

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.automata;
package com.baeldung.math.automata;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.automata;
package com.baeldung.math.automata;
/**
* State. Part of a finite state machine.

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.automata;
package com.baeldung.math.automata;
/**
* Transition in a finite State machine.

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.binarysearch;
package com.baeldung.math.binarysearch;
import java.util.Arrays;
import java.util.Collections;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.combination;
package com.baeldung.math.combination;
import java.util.Arrays;
import java.util.Iterator;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.combination;
package com.baeldung.math.combination;
import org.paukov.combinatorics3.Generator;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.combination;
package com.baeldung.math.combination;
import java.util.Arrays;
import java.util.Set;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.combination;
package com.baeldung.math.combination;
import java.util.ArrayList;
import java.util.Arrays;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.combination;
package com.baeldung.math.combination;
import java.util.ArrayList;
import java.util.Arrays;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.combination;
package com.baeldung.math.combination;
import java.util.ArrayList;
import java.util.Arrays;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.enumstatemachine;
package com.baeldung.math.enumstatemachine;
public enum LeaveRequestState {

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.factorial;
package com.baeldung.math.factorial;
import java.math.BigInteger;
import java.util.stream.LongStream;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.hillclimbing;
package com.baeldung.math.hillclimbing;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.hillclimbing;
package com.baeldung.math.hillclimbing;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.kthlargest;
package com.baeldung.math.kthlargest;
import java.util.Arrays;
import java.util.Collections;

View File

@@ -1,10 +1,10 @@
package com.baeldung.algorithms.mcts.montecarlo;
package com.baeldung.math.mcts.montecarlo;
import java.util.List;
import com.baeldung.algorithms.mcts.tictactoe.Board;
import com.baeldung.algorithms.mcts.tree.Node;
import com.baeldung.algorithms.mcts.tree.Tree;
import com.baeldung.math.mcts.tictactoe.Board;
import com.baeldung.math.mcts.tree.Node;
import com.baeldung.math.mcts.tree.Tree;
public class MonteCarloTreeSearch {

View File

@@ -1,10 +1,10 @@
package com.baeldung.algorithms.mcts.montecarlo;
package com.baeldung.math.mcts.montecarlo;
import java.util.ArrayList;
import java.util.List;
import com.baeldung.algorithms.mcts.tictactoe.Board;
import com.baeldung.algorithms.mcts.tictactoe.Position;
import com.baeldung.math.mcts.tictactoe.Board;
import com.baeldung.math.mcts.tictactoe.Position;
public class State {
private Board board;

View File

@@ -1,10 +1,9 @@
package com.baeldung.algorithms.mcts.montecarlo;
package com.baeldung.math.mcts.montecarlo;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.baeldung.algorithms.mcts.tree.Node;
import com.baeldung.math.mcts.tree.Node;
public class UCT {

View File

@@ -1,7 +1,6 @@
package com.baeldung.algorithms.mcts.tictactoe;
package com.baeldung.math.mcts.tictactoe;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Board {

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.mcts.tictactoe;
package com.baeldung.math.mcts.tictactoe;
public class Position {
int x;

View File

@@ -1,11 +1,11 @@
package com.baeldung.algorithms.mcts.tree;
package com.baeldung.math.mcts.tree;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import com.baeldung.algorithms.mcts.montecarlo.State;
import com.baeldung.math.mcts.montecarlo.State;
public class Node {
State state;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.mcts.tree;
package com.baeldung.math.mcts.tree;
public class Tree {
Node root;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.middleelementlookup;
package com.baeldung.math.middleelementlookup;
import java.util.LinkedList;
import java.util.Optional;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.middleelementlookup;
package com.baeldung.math.middleelementlookup;
public class Node {
private Node next;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.minimax;
package com.baeldung.math.minimax;
import java.util.List;
import java.util.stream.Collectors;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.minimax;
package com.baeldung.math.minimax;
import java.util.Comparator;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.minimax;
package com.baeldung.math.minimax;
import java.util.ArrayList;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.minimax;
package com.baeldung.math.minimax;
public class Tree {
private Node root;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.multiswarm;
package com.baeldung.math.multiswarm;
/**
* Constants used by the Multi-swarm optimization algorithms.

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.multiswarm;
package com.baeldung.math.multiswarm;
/**
* Interface for a fitness function, used to decouple the main algorithm logic

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.multiswarm;
package com.baeldung.math.multiswarm;
import java.util.Arrays;
import java.util.Random;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.multiswarm;
package com.baeldung.math.multiswarm;
import java.util.Arrays;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.multiswarm;
package com.baeldung.math.multiswarm;
import java.util.Arrays;
import java.util.Random;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.permutation;
package com.baeldung.math.permutation;
import java.util.Arrays;
import java.util.Collections;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.string;
package com.baeldung.math.string;
public class EnglishAlphabetLetters {

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.string;
package com.baeldung.math.string;
import java.util.HashMap;
import java.util.HashSet;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.string;
package com.baeldung.math.string;
import java.util.HashSet;
import java.util.Set;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.string.search;
package com.baeldung.math.string.search;
import java.math.BigInteger;
import java.util.Random;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.twopointertechnique;
package com.baeldung.math.twopointertechnique;
public class LinkedListFindMiddle {

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.twopointertechnique;
package com.baeldung.math.twopointertechnique;
public class MyNode<E> {
MyNode<E> next;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.twopointertechnique;
package com.baeldung.math.twopointertechnique;
public class RotateArray {

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.twopointertechnique;
package com.baeldung.math.twopointertechnique;
public class TwoSum {

View File

@@ -1,40 +0,0 @@
package com.baeldung.algorithms.linesintersection;
import java.awt.Point;
import java.util.Optional;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
public class LinesIntersectionServiceUnitTest {
private LinesIntersectionService service = new LinesIntersectionService();
@Test
public void givenNotParallelLines_whenCalculatePoint_thenPresent() {
double m1 = 0;
double b1 = 0;
double m2 = 1;
double b2 = -1;
Optional<Point> point = service.calculateIntersectionPoint(m1, b1, m2, b2);
assertTrue(point.isPresent());
assertEquals(point.get().getX(), 1, 0.001);
assertEquals(point.get().getY(), 0, 0.001);
}
@Test
public void givenParallelLines_whenCalculatePoint_thenEmpty() {
double m1 = 1;
double b1 = 0;
double m2 = 1;
double b2 = -1;
Optional<Point> point = service.calculateIntersectionPoint(m1, b1, m2, b2);
assertFalse(point.isPresent());
}
}

View File

@@ -1,7 +1,7 @@
package com.baeldung.algorithms;
package com.baeldung.math;
import com.baeldung.algorithms.hillclimbing.HillClimbing;
import com.baeldung.algorithms.hillclimbing.State;
import com.baeldung.math.hillclimbing.HillClimbing;
import com.baeldung.math.hillclimbing.State;
import org.junit.Before;
import org.junit.Test;

View File

@@ -1,7 +1,7 @@
package com.baeldung.algorithms;
package com.baeldung.math;
import com.baeldung.algorithms.middleelementlookup.MiddleElementLookup;
import com.baeldung.algorithms.middleelementlookup.Node;
import com.baeldung.math.middleelementlookup.MiddleElementLookup;
import com.baeldung.math.middleelementlookup.Node;
import org.junit.Test;
import java.util.LinkedList;

View File

@@ -1,6 +1,6 @@
package com.baeldung.algorithms;
package com.baeldung.math;
import com.baeldung.algorithms.automata.*;
import com.baeldung.math.automata.*;
import org.junit.Test;
import static org.junit.Assert.assertTrue;

View File

@@ -1,10 +1,10 @@
package com.baeldung.algorithms;
package com.baeldung.math;
import org.junit.Assert;
import org.junit.Test;
import com.baeldung.algorithms.string.search.StringSearchAlgorithms;
import com.baeldung.math.string.search.StringSearchAlgorithms;
public class StringSearchAlgorithmsUnitTest {

View File

@@ -1,11 +1,10 @@
package com.baeldung.algorithms.binarysearch;
package com.baeldung.math.binarysearch;
import java.util.Arrays;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import com.baeldung.algorithms.binarysearch.BinarySearch;
public class BinarySearchUnitTest {

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.combination;
package com.baeldung.math.combination;
import static org.junit.jupiter.api.Assertions.assertEquals;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.enumstatemachine;
package com.baeldung.math.enumstatemachine;
import static org.junit.Assert.assertEquals;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.factorial;
package com.baeldung.math.factorial;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.kthlargest;
package com.baeldung.math.kthlargest;
import static org.assertj.core.api.Assertions.*;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.mcts;
package com.baeldung.math.mcts;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -8,12 +8,12 @@ import java.util.List;
import org.junit.Before;
import org.junit.Test;
import com.baeldung.algorithms.mcts.montecarlo.MonteCarloTreeSearch;
import com.baeldung.algorithms.mcts.montecarlo.State;
import com.baeldung.algorithms.mcts.montecarlo.UCT;
import com.baeldung.algorithms.mcts.tictactoe.Board;
import com.baeldung.algorithms.mcts.tictactoe.Position;
import com.baeldung.algorithms.mcts.tree.Tree;
import com.baeldung.math.mcts.montecarlo.MonteCarloTreeSearch;
import com.baeldung.math.mcts.montecarlo.State;
import com.baeldung.math.mcts.montecarlo.UCT;
import com.baeldung.math.mcts.tictactoe.Board;
import com.baeldung.math.mcts.tictactoe.Position;
import com.baeldung.math.mcts.tree.Tree;
public class MCTSUnitTest {
private Tree gameTree;

View File

@@ -1,11 +1,9 @@
package com.baeldung.algorithms.minimax;
package com.baeldung.math.minimax;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import com.baeldung.algorithms.minimax.MiniMax;
import com.baeldung.algorithms.minimax.Tree;
public class MinimaxUnitTest {
private Tree gameTree;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.multiswarm;
package com.baeldung.math.multiswarm;
/**
* Specific fitness function implementation to solve the League of Legends

View File

@@ -1,10 +1,10 @@
package com.baeldung.algorithms.multiswarm;
package com.baeldung.math.multiswarm;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import com.baeldung.algorithms.support.MayFailRule;
import com.baeldung.math.support.MayFailRule;
/**
* Test for {@link Multiswarm}.

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.string;
package com.baeldung.math.string;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

View File

@@ -1,10 +1,10 @@
package com.baeldung.algorithms.string;
package com.baeldung.math.string;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static com.baeldung.algorithms.string.LongestSubstringNonRepeatingCharacters.getUniqueCharacterSubstring;
import static com.baeldung.algorithms.string.LongestSubstringNonRepeatingCharacters.getUniqueCharacterSubstringBruteForce;
import static com.baeldung.math.string.LongestSubstringNonRepeatingCharacters.getUniqueCharacterSubstring;
import static com.baeldung.math.string.LongestSubstringNonRepeatingCharacters.getUniqueCharacterSubstringBruteForce;
public class LongestSubstringNonRepeatingCharactersUnitTest {

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.string;
package com.baeldung.math.string;
import static org.junit.Assert.assertEquals;
import java.util.HashSet;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.support;
package com.baeldung.math.support;
import org.junit.Rule;
import org.junit.rules.TestRule;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.twopointertechnique;
package com.baeldung.math.twopointertechnique;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.twopointertechnique;
package com.baeldung.math.twopointertechnique;
import static org.assertj.core.api.Assertions.assertThat;

View File

@@ -1,4 +1,4 @@
package com.baeldung.algorithms.twopointertechnique;
package com.baeldung.math.twopointertechnique;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;