diff --git a/CMakePack.txt b/CMakePack.txt new file mode 100644 index 0000000..45ed2b2 --- /dev/null +++ b/CMakePack.txt @@ -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) \ No newline at end of file diff --git a/CMakeTests.txt b/CMakeTests.txt new file mode 100644 index 0000000..d37b306 --- /dev/null +++ b/CMakeTests.txt @@ -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) \ No newline at end of file diff --git a/include/list.h b/include/list.h new file mode 100644 index 0000000..2b7efe2 --- /dev/null +++ b/include/list.h @@ -0,0 +1,20 @@ +#ifndef __ODS_LIST__ +#define __ODS_LIST__ + + +#include + + +// Lists are sequences of values. +template +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 \ No newline at end of file diff --git a/include/queue.h b/include/queue.h new file mode 100644 index 0000000..6080d3f --- /dev/null +++ b/include/queue.h @@ -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 +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 \ No newline at end of file diff --git a/notes/chapter1.txt b/notes/chapter1.txt index af54fcc..bf0dc17 100644 --- a/notes/chapter1.txt +++ b/notes/chapter1.txt @@ -20,3 +20,49 @@ Concerns: * Priority queue: elements are inserted with a priority, and the smallest element is removed. This function is usually called `deleteMin`. * 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 \ No newline at end of file