Initial import.
This commit is contained in:
commit
983942712a
|
@ -0,0 +1,64 @@
|
||||||
|
SET(MAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
SET(CMAKE_BUILD_TYPE Debug CACHE STRING "default to debug" FORCE)
|
||||||
|
set(CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
# Basic project setup.
|
||||||
|
cmake_minimum_required(VERSION 3.5) # Xenial's CMake version.
|
||||||
|
project(ods)
|
||||||
|
set (${PROJECT_NAME}_VERSION_MAJOR 0)
|
||||||
|
set (${PROJECT_NAME}_VERSION_MINOR 1)
|
||||||
|
|
||||||
|
# Require clang.
|
||||||
|
set(CC clang)
|
||||||
|
set(CXX clang++)
|
||||||
|
|
||||||
|
# Set C++ compile flags for all builds.
|
||||||
|
add_compile_options(-Wall -Wextra -pedantic -Wshadow -Wpointer-arith)
|
||||||
|
add_compile_options(-Wcast-align -Wwrite-strings -Wmissing-declarations)
|
||||||
|
add_compile_options(-Werror -Wunused-variable -fno-elide-constructors)
|
||||||
|
|
||||||
|
# These might be contentious.
|
||||||
|
add_compile_options(-Weffc++)
|
||||||
|
# add_compile_options(-std=c++14)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
|
add_compile_options(-O0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE MATCHES RELEASE)
|
||||||
|
add_compile_options(-O2)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_GENERATOR MATCHES "Unix Makefiles")
|
||||||
|
SET(CMAKE_COLOR_MAKEFILE ON)
|
||||||
|
SET(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(GLOB_RECURSE SOURCES src/*.cc src/*.cpp)
|
||||||
|
file(GLOB_RECURSE HEADERS include/*.h)
|
||||||
|
file(GLOB HEADIRS include/*) # ha ha ha
|
||||||
|
|
||||||
|
include_directories(include test/include)
|
||||||
|
|
||||||
|
# Build shared library that can be reloaded while testing.
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||||
|
|
||||||
|
# Add static library for inclusion in final builds.
|
||||||
|
add_library(${PROJECT_NAME}-static STATIC ${SOURCES})
|
||||||
|
|
||||||
|
# Require C++14.
|
||||||
|
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
|
||||||
|
set_property(TARGET ${PROJECT_NAME}-static PROPERTY CXX_STANDARD 14)
|
||||||
|
|
||||||
|
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
set_property(TARGET ${PROJECT_NAME}-static PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
# Set up the library installation target.
|
||||||
|
install(TARGETS ${PROJECT_NAME} DESTINATION lib/${PROJECT_NAME})
|
||||||
|
install(TARGETS ${PROJECT_NAME}-static DESTINATION lib/${PROJECT_NAME})
|
||||||
|
|
||||||
|
# Install the headers.
|
||||||
|
install(DIRECTORY ${HEADIRS} DESTINATION include/${PROJECT_NAME})
|
||||||
|
|
||||||
|
# include(CMakeTests.txt)
|
||||||
|
# include(CMakePack.txt)
|
|
@ -0,0 +1,16 @@
|
||||||
|
# ODS
|
||||||
|
## Open Data Structures
|
||||||
|
|
||||||
|
This is an implementation and playground for the code in the
|
||||||
|
[Open Data Structures](http://opendatastructures.org/) books.
|
||||||
|
It contains both the C++ and Python repos.
|
||||||
|
|
||||||
|
Tree:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── include # C++ headers
|
||||||
|
├── notes # notes from the text
|
||||||
|
├── ods # Python sources
|
||||||
|
└── src # C++ sources
|
||||||
|
```
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Chapter 1
|
||||||
|
|
||||||
|
## Efficiency
|
||||||
|
|
||||||
|
Concerns:
|
||||||
|
1. Number of operations
|
||||||
|
2. Processor speeds
|
||||||
|
3. Storage space
|
||||||
|
|
||||||
|
## Interfaces
|
||||||
|
|
||||||
|
* Interface / abstract data type
|
||||||
|
|
||||||
|
### Queue interface
|
||||||
|
|
||||||
|
* `add(x)` (aka `queue`): add `x` to the queue
|
||||||
|
* `remove()` (aka `dequeue`): remove the next value from queue and return it
|
||||||
|
|
||||||
|
* Normal queue: the first element inserted is removed first
|
||||||
|
* 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`.
|
Loading…
Reference in New Issue