Dumping some WIP stuff.

This commit is contained in:
Kyle Isom 2017-11-09 06:10:20 -08:00
parent 983942712a
commit ebe583f22d
5 changed files with 112 additions and 0 deletions

18
CMakePack.txt Normal file
View File

@ -0,0 +1,18 @@
# build a CPack driven installer package
include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}")
# Debian settings
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "K. Isom")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "library of data structures")
set(CPACK_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc++1 (>= 3.7.0-1)")
# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
set(CPACK_DEBIAN_PACKAGE_SECTION devel)
# actually do the thing
set(CPACK_GENERATOR DEB)
include (CPack)

12
CMakeTests.txt Normal file
View File

@ -0,0 +1,12 @@
# Set up tests.
enable_testing()
# sctest tests
add_executable(simple_suite_example test/test/simple_suite_example.cpp)
target_link_libraries(simple_suite_example ${PROJECT_NAME}-static)
add_test(SimpleSuite_example, simple_suite_example)
# math tests
add_executable(geom2d_test test/math/geom2d_test.cpp)
target_link_libraries(geom2d_test ${PROJECT_NAME}-static)
add_test(geom2d_test geom2d_test)

20
include/list.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef __ODS_LIST__
#define __ODS_LIST__
#include <cstddef>
// Lists are sequences of values.
template <typename T>
class List {
public:
virtual std::size_t size(void);
virtual T get(std::size_t);
virtual T set(std::size_t, T);
virtual void add(std:size_t, T);
virtual T remove(std::size_t);
};
#endif

16
include/queue.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef __ODS_QUEUE__
#define __ODS_QUEUE__
// Dequeue represents a collection of elements to which we can add elements
// and remove the next element.
template<typename T>
class Dequeue {
public:
virtual void add_first(T);
virtual void add_last(T);
virtual T remove_first(void);
virtual T remove_last(void);
virtual bool empty(void);
};
#endif

View File

@ -20,3 +20,49 @@ Concerns:
* Priority queue: elements are inserted with a priority, and the smallest * Priority queue: elements are inserted with a priority, and the smallest
element is removed. This function is usually called `deleteMin`. element is removed. This function is usually called `deleteMin`.
* LIFO queue: a stack; add and remove are called `push` and `pop`. * LIFO queue: a stack; add and remove are called `push` and `pop`.
* Deque: generalisation of these
* `addFirst(x)`
* `removeFirst(x)`
* `addLast(x)`
* `removeLast(x)`
* Stack: addFirst, removeFirst
* Queue: addLast, removeFirst
### List interface
The List interface subsumes the Queue interface. A list is just a sequence of
values, and a Queue becomes a special case of it.
Interface:
* size()
* get(i): get i'th element
* set(i, x): set the i'th element to x
* add(i, x): insert x at position i
* remove(i): remove the i'th element
### USet (unordered sets)
USets are a collection of unique items in no particular order; this mimics a
mathematical set.
Interface:
* `size()`: returns the number of elements in the set
* `add(x)`: add x to the set if it doesn't already exist
* `remove(x)`: remove x from the set if it doesn't already exist
* `find(y)`: membership test
Note that y and x may be distinct objects, and only need to satisfy an
equality test. For example, a dictionary or hashmap is created using a tuple
`(key, value)`; `find` compares on `key` and two objects are considered equal
if their keys match.
### SSet (sorted set)
A USet where order matters. Its interface only changes in the `find` function:
* `find(x)`: find the smallest y s.t. y >= x. thereby returning a useful value
even if x isn't in the set. AKA successor search.
Difference between USet and SSet