aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/algorithms/algorithm.py
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-04-17 00:49:33 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-04-17 00:49:33 +0300
commit2183f3f860af34e45058ef078045322062b51f42 (patch)
tree1f61c51be301db314720fe4a945d6ddaaffa8249 /algorithms/algorithm.py
parentREADME update (diff)
downloadsorting-algorithms-2183f3f860af34e45058ef078045322062b51f42.tar.gz
sorting-algorithms-2183f3f860af34e45058ef078045322062b51f42.zip
rearrange source files
* Add a useful `algorithms` package to provide convinient access to the implemented algorithms. * This allows to e.g. dynamically list available algorithms, which greatly simplifies a lot of things.
Diffstat (limited to 'algorithms/algorithm.py')
-rw-r--r--algorithms/algorithm.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/algorithms/algorithm.py b/algorithms/algorithm.py
new file mode 100644
index 0000000..322a51f
--- /dev/null
+++ b/algorithms/algorithm.py
@@ -0,0 +1,25 @@
+# Copyright 2016 Egor Tensin <Egor.Tensin@gmail.com>
+# This file is licensed under the terms of the MIT License.
+# See LICENSE.txt for details.
+
+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
+
+ def get_function(self):
+ return self._f
+
+ def __str__(self):
+ return self.get_display_name()
+
+class SortingAlgorithm(Algorithm):
+ def __init__(self, codename, display_name, f):
+ super().__init__(codename, display_name, f)