Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separated operations and buffers from items agents. Added specializat…
…ion on Scala side. This change allows to have multiple different buffers used by a sorting algorithm without the need to implement a specialized items agent for it. Items buffers are grouped in flexible sort specific setups.
- Loading branch information
Showing
126 changed files
with
3,942 additions
and
2,817 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
29 changes: 0 additions & 29 deletions
29
core/main_scala/pl/tarsa/sortalgobox/core/common/ComparisonSortAlgorithm.scala
This file was deleted.
Oops, something went wrong.
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
62 changes: 62 additions & 0 deletions
62
core/main_scala/pl/tarsa/sortalgobox/core/common/ItemsAgentSortAlgorithm.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2015 - 2017 Piotr Tarsa ( http://github.com/tarsa ) | ||
* | ||
* This software is provided 'as-is', without any express or implied | ||
* warranty. In no event will the author be held liable for any damages | ||
* arising from the use of this software. | ||
* | ||
* Permission is granted to anyone to use this software for any purpose, | ||
* including commercial applications, and to alter it and redistribute it | ||
* freely, subject to the following restrictions: | ||
* | ||
* 1. The origin of this software must not be misrepresented; you must not | ||
* claim that you wrote the original software. If you use this software | ||
* in a product, an acknowledgment in the product documentation would be | ||
* appreciated but is not required. | ||
* 2. Altered source versions must be plainly marked as such, and must not be | ||
* misrepresented as being the original software. | ||
* 3. This notice may not be removed or altered from any source distribution. | ||
*/ | ||
package pl.tarsa.sortalgobox.core.common | ||
|
||
import pl.tarsa.sortalgobox.core.common.Specialization.{Group => Grp} | ||
import pl.tarsa.sortalgobox.core.common.items.agents.ItemsAgent | ||
import pl.tarsa.sortalgobox.core.common.items.buffers.NumericItemsBuffer.Evidence | ||
|
||
import scala.language.higherKinds | ||
import scala.{specialized => spec} | ||
|
||
sealed abstract class ItemsAgentSortAlgorithm[Info[_]] { | ||
protected type Agent[_] = ItemsAgent | ||
|
||
type Setup[@spec(Grp) _] | ||
|
||
def setupSort[@spec(Grp) Item: Info](items: Array[Item]): Setup[Item] | ||
|
||
final def sortExplicit[@spec(Grp) Item](sortSetup: Setup[Item], | ||
itemsAgent: ItemsAgent): Unit = { | ||
implicit val setup: Setup[Item] = sortSetup | ||
implicit val agent: Agent[_] = itemsAgent | ||
sort() | ||
} | ||
|
||
protected def sort[@spec(Grp) Item: Setup, _: Agent](): Unit | ||
|
||
protected final def a(implicit itemsAgent: Agent[_]): ItemsAgent = | ||
itemsAgent | ||
|
||
protected final def setup[@spec(Grp) Item: Setup]: Setup[Item] = | ||
implicitly[Setup[Item]] | ||
|
||
sealed trait Permit[+Item] | ||
|
||
protected implicit def permit[Item]: Permit[Item] = thePermit | ||
|
||
private val thePermit = new Permit[Nothing] {} | ||
} | ||
|
||
abstract class ComparableItemsAgentSortAlgorithm | ||
extends ItemsAgentSortAlgorithm[Ordering] | ||
|
||
abstract class NumericItemsAgentSortAlgorithm | ||
extends ItemsAgentSortAlgorithm[Evidence] |
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
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
Oops, something went wrong.