diff --git a/.github/workflows/code-formatting.yml b/.github/workflows/code-formatting.yml deleted file mode 100644 index c74863c7c..000000000 --- a/.github/workflows/code-formatting.yml +++ /dev/null @@ -1,28 +0,0 @@ -# This workflow checks that the code in the repo is formatted according to the -# Google Java Style Guide - -name: Code Formatting Check - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Verify all Java files are formatted correctly according to the Google Java Style Guide - run: | - ./gradlew verifyGoogleJavaFormat - echo "Run the command './gradlew goJF' to fix Java formatting if this workflow fails" diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 8a80dd989..2c929682b 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -1,6 +1,3 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - name: Java CI with Gradle on: @@ -24,3 +21,11 @@ jobs: run: chmod +x gradlew - name: Run all tests run: ./gradlew test + + #check java style + - name: Java CheckStyle + uses: dbelyaev/action-checkstyle@v0.5.1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: warning diff --git a/.github/workflows/gradle2.yml b/.github/workflows/gradle2.yml new file mode 100644 index 000000000..170ef7bc7 --- /dev/null +++ b/.github/workflows/gradle2.yml @@ -0,0 +1,34 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Java CI with Gradle + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: build diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 000000000..fb0493403 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,40 @@ +name: SonarCloud analysis + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + +permissions: + pull-requests: read # allows SonarCloud to decorate PRs with analysis results + +jobs: + Analysis: + runs-on: ubuntu-latest + + steps: + - name: Analyze with SonarCloud + + # You can pin the exact commit or the version. + # uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 + uses: SonarSource/sonarcloud-github-action@de2e56b42aa84d0b1c5b622644ac17e505c9a049 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret) + with: + # Additional arguments for the sonarcloud scanner + args: + # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu) + # mandatory + -Dsonar.projectKey=EthelAw_Algorithms + -Dsonar.organization=ethelaw + # Comma-separated paths to directories containing main source files. + #-Dsonar.sources= # optional, default is project base directory + # When you need the analysis to take place in a directory other than the one from which it was launched + #-Dsonar.projectBaseDir= # optional, default is . + # Comma-separated paths to directories containing test source files. + #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/ + # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing. + #-Dsonar.verbose= # optional, default is false diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 000000000..e69de29bb diff --git a/.metadata/.log b/.metadata/.log new file mode 100644 index 000000000..2c23423b1 --- /dev/null +++ b/.metadata/.log @@ -0,0 +1,28 @@ +!SESSION 2022-08-06 18:55:22.612 ----------------------------------------------- +eclipse.buildId=4.15.0.I20200305-0155 +java.version=1.8.0_281 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_MY +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY org.eclipse.egit.ui 2 0 2022-08-06 18:56:13.311 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Admin_pc'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. +!SESSION 2022-08-06 18:59:55.424 ----------------------------------------------- +eclipse.buildId=4.15.0.I20200305-0155 +java.version=1.8.0_281 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_MY +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY org.eclipse.egit.ui 2 0 2022-08-06 19:00:33.030 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Admin_pc'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. diff --git a/.metadata/.mylyn/.taskListIndex/segments_1 b/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 000000000..9511bc23f Binary files /dev/null and b/.metadata/.mylyn/.taskListIndex/segments_1 differ diff --git a/.metadata/.mylyn/.taskListIndex/write.lock b/.metadata/.mylyn/.taskListIndex/write.lock new file mode 100644 index 000000000..e69de29bb diff --git a/.metadata/.mylyn/.tasks.xml.zip b/.metadata/.mylyn/.tasks.xml.zip new file mode 100644 index 000000000..f7a59cb1f Binary files /dev/null and b/.metadata/.mylyn/.tasks.xml.zip differ diff --git a/.metadata/.mylyn/repositories.xml.zip b/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 000000000..c03308804 Binary files /dev/null and b/.metadata/.mylyn/repositories.xml.zip differ diff --git a/.metadata/.mylyn/tasks.xml.zip b/.metadata/.mylyn/tasks.xml.zip new file mode 100644 index 000000000..a74a07197 Binary files /dev/null and b/.metadata/.mylyn/tasks.xml.zip differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 000000000..25cb955ba --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 000000000..ed9b51496 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 000000000..6b2aaa764 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree new file mode 100644 index 000000000..8a1fc9ec5 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 000000000..8d5f2fbd6 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 000000000..f5123dc6b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2326 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + + + + org.eclipse.e4.primaryNavigationStack + active + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + + + + + + View + categoryTag:Mylyn + + + + org.eclipse.e4.secondaryNavigationStack + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Ant + + + + + + org.eclipse.e4.secondaryDataStack + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + org.eclipse.e4.primaryDataStack + EditorStack + + + + + + + View + categoryTag:Java + active + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Git + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Team + + + + + View + categoryTag:Team + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 000000000..593f4708d Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 000000000..593f4708d Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 000000000..593f4708d Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 000000000..0edae4b20 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 000000000..a4ee3cbc9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 000000000..9e390f501 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 000000000..124bc0823 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,10 @@ + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 000000000..ec33b9d43 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log @@ -0,0 +1,2 @@ +2022-08-06 18:56:12,689 [Worker-3: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is out-of-date. Trying to update. +2022-08-06 19:00:32,533 [Worker-2: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. diff --git a/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml new file mode 100644 index 000000000..e33758c3a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml @@ -0,0 +1,43 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 000000000..1f73e14c1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 000000000..5ca0b7769 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 000000000..07a485437 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,9 @@ + +
+
+ + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.intro/introstate b/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 000000000..02f134f0f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 000000000..5b583c4be --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,5 @@ + +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 000000000..38ee6d832 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.metadata/version.ini b/.metadata/version.ini new file mode 100644 index 000000000..e44d6b87e --- /dev/null +++ b/.metadata/version.ini @@ -0,0 +1,3 @@ +#Sat Aug 06 19:00:23 SGT 2022 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.15.0.v20200305-0155 diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.lock b/src/main/java/com/williamfiset/algorithms/search/.metadata/.lock new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.log b/src/main/java/com/williamfiset/algorithms/search/.metadata/.log new file mode 100644 index 000000000..871104f44 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.log @@ -0,0 +1,30 @@ +!SESSION 2022-08-06 18:56:43.727 ----------------------------------------------- +eclipse.buildId=4.15.0.I20200305-0155 +java.version=1.8.0_281 +java.vendor=Oracle Corporation +BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_MY +Framework arguments: -product org.eclipse.epp.package.java.product +Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product + +!ENTRY org.eclipse.egit.ui 2 0 2022-08-06 18:57:15.421 +!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git +user global configuration and to define the default location to store repositories: 'C:\Users\Admin_pc'. If this is +not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and +EGit might behave differently since they see different configuration options. +This warning can be switched off on the Team > Git > Confirmations and Warnings preference page. + +!ENTRY org.eclipse.ui.ide 4 0 2022-08-06 18:59:32.425 +!MESSAGE Could not import project located at C:\Users\Admin_pc\Algorithms\src\main\java\com\williamfiset\algorithms\search +!STACK 0 +org.eclipse.ui.internal.wizards.datatransfer.CouldNotImportProjectException: Could not import project located at C:\Users\Admin_pc\Algorithms\src\main\java\com\williamfiset\algorithms\search + at org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob.toExistingOrNewProject(SmartImportJob.java:565) + at org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob.run(SmartImportJob.java:252) + at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) +Caused by: org.eclipse.core.internal.resources.ResourceException: Invalid project description. + at org.eclipse.core.internal.resources.Project.checkDescription(Project.java:173) + at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:57) + at org.eclipse.core.internal.resources.Project.create(Project.java:266) + at org.eclipse.core.internal.resources.Project.create(Project.java:252) + at org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob.createOrImportProject(SmartImportJob.java:604) + at org.eclipse.ui.internal.wizards.datatransfer.SmartImportJob.toExistingOrNewProject(SmartImportJob.java:552) + ... 2 more diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/segments_1 b/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 000000000..24f6e7697 Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/segments_1 differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/write.lock b/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/.taskListIndex/write.lock new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/repositories.xml.zip b/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/repositories.xml.zip new file mode 100644 index 000000000..3856633c1 Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/repositories.xml.zip differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/tasks.xml.zip b/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/tasks.xml.zip new file mode 100644 index 000000000..5dc98b1c1 Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.mylyn/tasks.xml.zip differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 000000000..25cb955ba --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 000000000..ed9b51496 Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 000000000..6b2aaa764 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree new file mode 100644 index 000000000..8a1fc9ec5 Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.root/1.tree differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 000000000..3e3447e04 Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 000000000..0da786e1d --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2326 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + ModelMigrationProcessor.001 + + + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.doc.actionSet + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.ResourceNavigator + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + + + + org.eclipse.e4.primaryNavigationStack + active + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + + + + + + View + categoryTag:Mylyn + + + + org.eclipse.e4.secondaryNavigationStack + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Ant + + + + + + org.eclipse.e4.secondaryDataStack + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + org.eclipse.e4.primaryDataStack + EditorStack + + + + + + + View + categoryTag:Java + active + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Git + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Team + + + + + View + categoryTag:Team + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:XML + + + + + View + categoryTag:XML + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 000000000..593f4708d Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 000000000..593f4708d Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 000000000..593f4708d Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 000000000..0edae4b20 Binary files /dev/null and b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml new file mode 100644 index 000000000..754875573 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml new file mode 100644 index 000000000..4780ec2b0 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 000000000..a4ee3cbc9 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 000000000..9e390f501 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 000000000..40c861b1e --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,12 @@ + +
+ + +
+ + + + + +
+
diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log new file mode 100644 index 000000000..e030750b9 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log @@ -0,0 +1 @@ +2022-08-06 18:57:14,937 [Worker-2: Loading available Gradle versions] INFO o.e.b.c.i.u.g.PublishedGradleVersions - Gradle version information cache is up-to-date. Trying to read. diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml new file mode 100644 index 000000000..e33758c3a --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml @@ -0,0 +1,43 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + OFF + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 100MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 000000000..1f73e14c1 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 000000000..5ca0b7769 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml new file mode 100644 index 000000000..00618f758 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml @@ -0,0 +1,12 @@ + +
+
+ + + + + + + +
+
diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.intro/introstate b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 000000000..02f134f0f --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 000000000..5ca0b7769 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 000000000..528058008 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/com/williamfiset/algorithms/search/.metadata/version.ini b/src/main/java/com/williamfiset/algorithms/search/.metadata/version.ini new file mode 100644 index 000000000..0c1fcc802 --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/.metadata/version.ini @@ -0,0 +1,3 @@ +#Sat Aug 06 18:57:00 SGT 2022 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.15.0.v20200305-0155 diff --git a/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java b/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java new file mode 100644 index 000000000..0f3239cea --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/KMPSearch.java @@ -0,0 +1,83 @@ +package com.thealgorithms.searches; + +class KMPSearch { + int KMPSearch(String pat, String txt) + { + int M = pat.length(); + int N = txt.length(); + + // create lps[] that will hold the longest + // prefix suffix values for pattern + int lps[] = new int[M]; + int j = 0; // index for pat[] + + // Preprocess the pattern (calculate lps[] + // array) + computeLPSArray(pat, M, lps); + + int i = 0; // index for txt[] + while ((N - i) >= (M - j)) { + if (pat.charAt(j) == txt.charAt(i)) { + j++; + i++; + } + if (j == M) { + System.out.println("Found pattern " + + "at index " + (i - j)); + int index = (i - j); + j = lps[j - 1]; + return index; + + } + + // mismatch after j matches + else if (i < N && pat.charAt(j) != txt.charAt(i)) { + // Do not match lps[0..lps[j-1]] characters, + // they will match anyway + if (j != 0) + j = lps[j - 1]; + else + i = i + 1; + } + } + System.out.println("No pattern found"); + return -1; + } + + void computeLPSArray(String pat, int M, int lps[]) + { + // length of the previous longest prefix suffix + int len = 0; + int i = 1; + lps[0] = 0; // lps[0] is always 0 + + // the loop calculates lps[i] for i = 1 to M-1 + while (i < M) { + if (pat.charAt(i) == pat.charAt(len)) { + len++; + lps[i] = len; + i++; + } + else // (pat[i] != pat[len]) + { + // This is tricky. Consider the example. + // AAACAAAA and i = 7. The idea is similar + // to search step. + if (len != 0) { + len = lps[len - 1]; + + // Also, note that we do not increment + // i here + } + else // if (len == 0) + { + lps[i] = len; + i++; + } + } + } + } + + +} +// This code has been contributed by Amit Khandelwal. diff --git a/src/main/java/com/williamfiset/algorithms/search/QuickSelect.java b/src/main/java/com/williamfiset/algorithms/search/QuickSelect.java new file mode 100644 index 000000000..548fe1a9e --- /dev/null +++ b/src/main/java/com/williamfiset/algorithms/search/QuickSelect.java @@ -0,0 +1,138 @@ +import java.util.*; + +/** + * An implementation of the Quickselect algorithm as described + * here. + */ +public final class QuickSelect { + + /** + * Selects the {@code n}-th largest element of {@code list}, i.e. the element that would + * be at index n if the list was sorted. + *

+ * Calling this function might change the order of elements in {@code list}. + * + * @param list the list of elements + * @param n the index + * @param the type of list elements + * @return the n-th largest element in the list + * @throws IndexOutOfBoundsException if n is less than 0 or greater or equal to + * the number of elements in the list + * @throws IllegalArgumentException if the list is empty + * @throws NullPointerException if {@code list} is null + */ + public static > T select(List list, int n) { + Objects.requireNonNull(list, "The list of elements must not be null."); + + if (list.size() == 0) { + String msg = "The list of elements must not be empty."; + throw new IllegalArgumentException(msg); + } + + if (n < 0) { + String msg = "The index must not be negative."; + throw new IndexOutOfBoundsException(msg); + } + + if (n >= list.size()) { + String msg = "The index must be less than the number of elements."; + throw new IndexOutOfBoundsException(msg); + } + + int index = selectIndex(list, n); + return list.get(index); + } + + private static > int selectIndex(List list, int n) { + return selectIndex(list, 0, list.size() - 1, n); + } + + private static > int selectIndex( + List list, + int left, + int right, + int n + ) { + while (true) { + if (left == right) + return left; + int pivotIndex = pivot(list, left, right); + pivotIndex = partition(list, left, right, pivotIndex, n); + if (n == pivotIndex) { + return n; + } else if (n < pivotIndex) { + right = pivotIndex - 1; + } else { + left = pivotIndex + 1; + } + } + } + + private static > int partition( + List list, + int left, + int right, + int pivotIndex, + int n + ) { + T pivotValue = list.get(pivotIndex); + Collections.swap(list, pivotIndex, right); + int storeIndex = left; + + for (int i = left; i < right; i++) { + if (list.get(i).compareTo(pivotValue) < 0) { + Collections.swap(list, storeIndex, i); + storeIndex++; + } + } + + int storeIndexEq = storeIndex; + + for (int i = storeIndex; i < right; i++) { + if (list.get(i).compareTo(pivotValue) == 0) { + Collections.swap(list, storeIndexEq, i); + storeIndexEq++; + } + } + + Collections.swap(list, right, storeIndexEq); + + return (n < storeIndex) + ? storeIndex + : Math.min(n, storeIndexEq); + } + + private static > int pivot( + List list, + int left, + int right + ) { + if (right - left < 5) { + return partition5(list, left, right); + } + + for (int i = left; i < right; i += 5) { + int subRight = i + 4; + if (subRight > right) { + subRight = right; + } + int median5 = partition5(list, i, subRight); + int rightIndex = left + (i - left) / 5; + Collections.swap(list, median5, rightIndex); + } + + int mid = (right - left) / 10 + left + 1; + int rightIndex = left + (right - left) / 5; + return selectIndex(list, left, rightIndex, mid); + } + + private static > int partition5( + List list, + int left, + int right + ) { + List ts = list.subList(left, right); + ts.sort(Comparator.naturalOrder()); + return (left + right) >>> 1; + } +} \ No newline at end of file diff --git a/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java b/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java new file mode 100644 index 000000000..812f0725b --- /dev/null +++ b/src/test/java/com/williamfiset/algorithms/search/KMPSearchTest.java @@ -0,0 +1,65 @@ +package com.thealgorithms.searches; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class KMPSearchTest { + + @Test + // valid test case + public void KMPSearchTestLast() { + String txt = "ABABDABACDABABCABAB"; + String pat = "ABABCABAB"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 10); + + } + + @Test + // valid test case + public void KMPSearchTestFront() { + String txt = "AAAAABAAABA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 0); + + } + + @Test + // valid test case + public void KMPSearchTestMiddle() { + String txt = "AAACAAAAAC"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 4); + + } + @Test + // valid test case + public void KMPSearchTestNotFound() { + String txt = "AAABAAAA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, 4); + + } + @Test + // not valid test case + public void KMPSearchTest4() { + String txt = "AABAAA"; + String pat = "AAAA"; + KMPSearch kmpSearch = new KMPSearch(); + int value = kmpSearch.KMPSearch(pat, txt); + System.out.println(value); + assertEquals(value, -1); + + } +} diff --git a/src/test/java/com/williamfiset/algorithms/search/QuickSelectTest.java b/src/test/java/com/williamfiset/algorithms/search/QuickSelectTest.java new file mode 100644 index 000000000..b25918eeb --- /dev/null +++ b/src/test/java/com/williamfiset/algorithms/search/QuickSelectTest.java @@ -0,0 +1,242 @@ +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +import org.junit.jupiter.api.Test; + +import java.util.*; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.*; + +class QuickSelectTest { + @Test + void quickSelectMinimumOfOneElement() { + List elements = Collections.singletonList(42); + int minimum = QuickSelect.select(elements, 0); + assertEquals(42, minimum); + } + + @Test + void quickSelectMinimumOfTwoElements() { + List elements1 = Arrays.asList(42, 90); + List elements2 = Arrays.asList(90, 42); + + int minimum1 = QuickSelect.select(elements1, 0); + int minimum2 = QuickSelect.select(elements2, 0); + + assertEquals(42, minimum1); + assertEquals(42, minimum2); + } + + @Test + void quickSelectMinimumOfThreeElements() { + List elements1 = Arrays.asList(1, 2, 3); + List elements2 = Arrays.asList(2, 1, 3); + List elements3 = Arrays.asList(2, 3, 1); + + int minimum1 = QuickSelect.select(elements1, 0); + int minimum2 = QuickSelect.select(elements2, 0); + int minimum3 = QuickSelect.select(elements3, 0); + + assertEquals(1, minimum1); + assertEquals(1, minimum2); + assertEquals(1, minimum3); + } + + @Test + void quickSelectMinimumOfManyElements() { + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, 0); + int expected = elements.stream().min(Comparator.naturalOrder()).get(); + assertEquals(expected, actual); + } + + @Test + void quickSelectMaximumOfOneElement() { + List elements = Collections.singletonList(42); + int maximum = QuickSelect.select(elements, 0); + assertEquals(42, maximum); + } + + @Test + void quickSelectMaximumOfTwoElements() { + List elements1 = Arrays.asList(42, 90); + List elements2 = Arrays.asList(90, 42); + + int maximum1 = QuickSelect.select(elements1, 1); + int maximum2 = QuickSelect.select(elements2, 1); + + assertEquals(90, maximum1); + assertEquals(90, maximum2); + } + + @Test + void quickSelectMaximumOfThreeElements() { + List elements1 = Arrays.asList(1, 2, 3); + List elements2 = Arrays.asList(2, 1, 3); + List elements3 = Arrays.asList(2, 3, 1); + + int maximum1 = QuickSelect.select(elements1, 2); + int maximum2 = QuickSelect.select(elements2, 2); + int maximum3 = QuickSelect.select(elements3, 2); + + assertEquals(3, maximum1); + assertEquals(3, maximum2); + assertEquals(3, maximum3); + } + + @Test + void quickSelectMaximumOfManyElements() { + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, NUM_RND_ELEMENTS - 1); + int expected = elements.stream().max(Comparator.naturalOrder()).get(); + assertEquals(expected, actual); + } + + @Test + void quickSelectMedianOfOneElement() { + List elements = Collections.singletonList(42); + int median = QuickSelect.select(elements, 0); + assertEquals(42, median); + } + + @Test + void quickSelectMedianOfThreeElements() { + List elements1 = Arrays.asList(1, 2, 3); + List elements2 = Arrays.asList(2, 1, 3); + List elements3 = Arrays.asList(2, 3, 1); + + int median1 = QuickSelect.select(elements1, 1); + int median2 = QuickSelect.select(elements2, 1); + int median3 = QuickSelect.select(elements3, 1); + + assertEquals(2, median1); + assertEquals(2, median2); + assertEquals(2, median3); + } + + @Test + void quickSelectMedianOfManyElements() { + int medianIndex = NUM_RND_ELEMENTS / 2; + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, medianIndex); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(medianIndex), actual); + } + + @Test + void quickSelect30thPercentileOf10Elements() { + List elements = generateRandomIntegers(10); + int actual = QuickSelect.select(elements, 2); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(2), actual); + } + + @Test + void quickSelect30thPercentileOfManyElements() { + int percentile30th = NUM_RND_ELEMENTS / 10 * 3; + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, percentile30th); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(percentile30th), actual); + } + + @Test + void quickSelect70thPercentileOf10Elements() { + List elements = generateRandomIntegers(10); + int actual = QuickSelect.select(elements, 6); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(6), actual); + } + + @Test + void quickSelect70thPercentileOfManyElements() { + int percentile70th = NUM_RND_ELEMENTS / 10 * 7; + List elements = generateRandomIntegers(NUM_RND_ELEMENTS); + int actual = QuickSelect.select(elements, percentile70th); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(percentile70th), actual); + } + + @Test + void quickSelectMedianOfThreeCharacters() { + List elements = Arrays.asList('X', 'Z', 'Y'); + char actual = QuickSelect.select(elements, 1); + assertEquals(actual, 'Y'); + } + + @Test + void quickSelectMedianOfManyCharacters() { + List elements = generateRandomCharacters(NUM_RND_ELEMENTS); + char actual = QuickSelect.select(elements, NUM_RND_ELEMENTS / 30); + + List elementsSorted = getSortedCopyOfList(elements); + assertEquals(elementsSorted.get(NUM_RND_ELEMENTS / 30), actual); + } + + @Test + void quickSelectNullList() { + NullPointerException exception = assertThrows( + NullPointerException.class, + () -> QuickSelect.select(null, 0) + ); + String expectedMsg = "The list of elements must not be null."; + assertEquals(expectedMsg, exception.getMessage()); + } + + @Test + void quickSelectEmptyList() { + List objects = Collections.emptyList(); + IllegalArgumentException exception = assertThrows( + IllegalArgumentException.class, + () -> QuickSelect.select(objects, 0) + ); + String expectedMsg = "The list of elements must not be empty."; + assertEquals(expectedMsg, exception.getMessage()); + } + + @Test + void quickSelectIndexOutOfLeftBound() { + IndexOutOfBoundsException exception = assertThrows( + IndexOutOfBoundsException.class, + () -> QuickSelect.select(Collections.singletonList(1), -1) + ); + String expectedMsg = "The index must not be negative."; + assertEquals(expectedMsg, exception.getMessage()); + } + + @Test + void quickSelectIndexOutOfRightBound() { + IndexOutOfBoundsException exception = assertThrows( + IndexOutOfBoundsException.class, + () -> QuickSelect.select(Collections.singletonList(1), 1) + ); + String expectedMsg = "The index must be less than the number of elements."; + assertEquals(expectedMsg, exception.getMessage()); + } + + private static final int NUM_RND_ELEMENTS = 99; + private static final Random RANDOM = new Random(42); + private static final int ASCII_A = 0x41; + private static final int ASCII_Z = 0x5A; + + private static List generateRandomIntegers(int n) { + return RANDOM.ints(n).boxed().collect(Collectors.toList()); + } + + private static List generateRandomCharacters(int n) { + return RANDOM.ints(n, ASCII_A, ASCII_Z) + .mapToObj(i -> (char) i) + .collect(Collectors.toList()); + } + + private static > List getSortedCopyOfList(List list) { + return list.stream().sorted().collect(Collectors.toList()); + } +} \ No newline at end of file