109 lines
3.3 KiB
Go
109 lines
3.3 KiB
Go
|
package endpoints
|
||
|
|
||
|
/* ---------------------------------------------------------------- *
|
||
|
* IMPORTS
|
||
|
* ---------------------------------------------------------------- */
|
||
|
|
||
|
import (
|
||
|
"ads/internal/core/logging"
|
||
|
"ads/internal/menus"
|
||
|
"ads/internal/setup"
|
||
|
"reflect"
|
||
|
|
||
|
// algorithm_search_binary "ads/internal/algorithms/search/binary"
|
||
|
// algorithm_search_interpol "ads/internal/algorithms/search/interpol"
|
||
|
// algorithm_search_ith_element "ads/internal/algorithms/search/ith_element"
|
||
|
// algorithm_search_jump "ads/internal/algorithms/search/jump"
|
||
|
// algorithm_search_poison "ads/internal/algorithms/search/poison"
|
||
|
algorithm_search_sequential "ads/internal/algorithms/search/sequential"
|
||
|
// algorithm_sum_maxsubsum "ads/internal/algorithms/sum/maxsubsum"
|
||
|
)
|
||
|
|
||
|
/* ---------------------------------------------------------------- *
|
||
|
* ENDPOINT run interactive modus
|
||
|
* ---------------------------------------------------------------- */
|
||
|
|
||
|
// Startet App im interaktiven Modus
|
||
|
func RunInteractive() error {
|
||
|
logging.LogPlain(setup.Logo())
|
||
|
_, err := menuMain.ShowMenu()
|
||
|
logging.LogInfo("Programm terminiert.")
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
/* ---------------------------------------------------------------- *
|
||
|
* MENUS
|
||
|
* ---------------------------------------------------------------- */
|
||
|
|
||
|
var menuMain = menus.Menu{
|
||
|
IsRoot: true,
|
||
|
Path: []string{"Hauptmenü"},
|
||
|
PromptMessages: []string{
|
||
|
"Option wählen",
|
||
|
},
|
||
|
Options: []menus.MenuOption{
|
||
|
{Label: "Version des Programms anzeigen", Action: actionShowVersion},
|
||
|
{Label: "Suchalgorithmen", Submenu: &menuSearchAlgorithms},
|
||
|
{Label: "Summenalgorithmen", Submenu: &menuSumAlgorithms},
|
||
|
},
|
||
|
DefaultOption: -1,
|
||
|
}
|
||
|
|
||
|
var menuSearchAlgorithms = menus.Menu{
|
||
|
IsRoot: false,
|
||
|
Path: []string{"Hauptmenü", "Suchalgorithmus"},
|
||
|
PromptMessages: []string{
|
||
|
"Algorithmus wählen",
|
||
|
},
|
||
|
Options: []menus.MenuOption{
|
||
|
{Label: "Binärsuchalgorithmus"},
|
||
|
{Label: "Interpolationsalgorithmus"},
|
||
|
{Label: "Suche i. kleinstes Element"},
|
||
|
{Label: "Suche i. kleinstes Element", SubLabel: "D & C"},
|
||
|
{Label: "Sprungsuche", SubLabel: "linear"},
|
||
|
{Label: "Sprungsuche", SubLabel: "exponentiell"},
|
||
|
{Label: "Giftsuche"},
|
||
|
{Label: "Giftsuche", SubLabel: "optimiert"},
|
||
|
{Label: "Sequentiellsuchalgorithmus", Action: actionAlgorithmSearchSequential},
|
||
|
},
|
||
|
DefaultOption: -1,
|
||
|
}
|
||
|
|
||
|
var menuSumAlgorithms = menus.Menu{
|
||
|
IsRoot: false,
|
||
|
Path: []string{"Hauptmenü", "Suchalgorithmus"},
|
||
|
PromptMessages: []string{
|
||
|
"Algorithmus wählen",
|
||
|
},
|
||
|
Options: []menus.MenuOption{
|
||
|
{Label: "Maximale Teilsumme", SubLabel: "brute force"},
|
||
|
{Label: "Maximale Teilsumme", SubLabel: "D & C"},
|
||
|
},
|
||
|
DefaultOption: -1,
|
||
|
}
|
||
|
|
||
|
/* ---------------------------------------------------------------- *
|
||
|
* ACTIONS - basic
|
||
|
* ---------------------------------------------------------------- */
|
||
|
|
||
|
func actionShowVersion() error {
|
||
|
logging.LogInfo("Version des Programms")
|
||
|
Version()
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
/* ---------------------------------------------------------------- *
|
||
|
* ACTIONS - Algorithmen
|
||
|
* ---------------------------------------------------------------- */
|
||
|
|
||
|
// TODO
|
||
|
func actionAlgorithmSearchSequential() error {
|
||
|
input_L := []int{45, 67}
|
||
|
input_x := 6
|
||
|
menus.PromptValue("L", "Liste von Integers", "z.B. \033[1m5 73 42\033[0m", reflect.TypeOf([]int{}))
|
||
|
setup.DisplayStartOfCaseBlank()
|
||
|
algorithm_search_sequential.FancySequentialSearch(input_L, input_x)
|
||
|
setup.DisplayEndOfCase()
|
||
|
return nil
|
||
|
}
|