diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-24 01:54:13 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-06-24 01:54:13 +0300 |
commit | 82a674e409fce161299efeb43e1176f869af64af (patch) | |
tree | 3b544bd96688f3847233e011452c754c38755116 /algorithms/algorithm.py | |
parent | add Pylint configuration (diff) | |
download | sorting-algorithms-82a674e409fce161299efeb43e1176f869af64af.tar.gz sorting-algorithms-82a674e409fce161299efeb43e1176f869af64af.zip |
major refactoring
With the focus on (re)usability.
That includes adding separate modules for plotting, input generation
and things like that.
Diffstat (limited to 'algorithms/algorithm.py')
-rw-r--r-- | algorithms/algorithm.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/algorithms/algorithm.py b/algorithms/algorithm.py index 322a51f..b65ed04 100644 --- a/algorithms/algorithm.py +++ b/algorithms/algorithm.py @@ -2,24 +2,22 @@ # This file is licensed under the terms of the MIT License. # See LICENSE.txt for details. +from . import inputgen + class Algorithm: def __init__(self, codename, display_name, f): - self._codename = codename - self._display_name = display_name - self._f = f - - def get_codename(self): - return self._codename - - def get_display_name(self): - return self._display_name + self.codename = codename + self.display_name = display_name + self.function = f - def get_function(self): - return self._f - - def __str__(self): - return self.get_display_name() + @staticmethod + def gen_input(n, case=inputgen.InputKind.AVERAGE): + #raise NotImplementedError('inputgen generation is not defined for generic algorithms') + return inputgen.gen_input_for_sorting(n, case) class SortingAlgorithm(Algorithm): def __init__(self, codename, display_name, f): super().__init__(codename, display_name, f) + + def gen_input(self, n, case=inputgen.InputKind.AVERAGE): + return inputgen.gen_input_for_sorting(n, case) |