Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BasedOnStyle: Google
IndentWidth: 4
Language: Cpp
# Force pointers to the type for C++.
DerivePointerAlignment: false
PointerAlignment: Right
20 changes: 20 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Checks: "-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming"
CheckOptions:
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.EnumCase
value: lower_case
- key: readability-identifier-naming.FunctionCase
value: CamelCase
- key: readability-identifier-naming.MemberCase
value: lower_case
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.UnionCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 1
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: "next|hasNext|begin|end"
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: leetcode.rs

# Run this workflow every time a new commit pushed to your repository
on:
push:
pull_request:

env:
RUSTFLAGS: -Dwarnings

jobs:
sanitize-test:
name: memleak test
runs-on: ubuntu-latest
container: ${{ matrix.container }}
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- run: sudo apt update && sudo apt install cmake build-essential libgtest-dev clang-12 -y
- run: |
cmake -B build -DBUILD_MEMLEAK=ON && cmake --build build && make -C build test

valgrind-test:
name: valgrind test
runs-on: ubuntu-latest
container: ${{ matrix.container }}
timeout-minutes: 45
steps:
- uses: actions/checkout@v3
- run: sudo apt update && sudo apt install cmake build-essential libgtest-dev clang-12 valgrind -y
- run: |
cmake -B build -DBUILD_MEMLEAK=OFF && cmake --build build && make -C build test
valgrind --tool=memcheck --leak-check=full ./build/skiplist

53 changes: 5 additions & 48 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,53 +1,10 @@
# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project

# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/
out/
build/
**/build/

.DS_Store
.DS_Store?

.gradle
production/

signing.properties

*~
#extras/external_tagsoup/

module/
captures/

cmake-build-debug/
.cmake-build-debug/

freeline/
freeline.py
freeline_project_description.json
/.idea
/cmake-build-debug
/build
/.cache
/compile_commands.json
24 changes: 22 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
cmake_minimum_required(VERSION 3.9)
project(SkipListPro)
project(skiplist)

set(CMAKE_CXX_STANDARD 11)

add_executable(SkipListPro main.cpp Node.h SkipList.h random.h)
enable_testing()

add_executable(skiplist src/main.cc src/node.h src/skiplist.h src/random.h)

# cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_MEMLEAK=ON -G Ninja -B build
# ninja -C build
# ctest --test-dir build --rerun-failed --output-on-failure
set(BUILD_FLAGS "-DDEBUG -g -Wall -Wpedantic" )
set(LD_FLAGS "")

if(BUILD_MEMLEAK)
set(BUILD_FLAGS "${BUILD_FLAGS} -fsanitize=address")
set(LD_FLAGS "-fsanitize=address")
endif()


target_compile_options(skiplist PRIVATE ${BUILD_FLAGS})
target_link_options(skiplist PRIVATE ${LD_FLAGS})

add_test(skip_list skiplist COMMAND skiplist WORKING_DIRECTORY
$(CMAKE_CURRENT_SOURCE_DIR))
57 changes: 0 additions & 57 deletions Node.h

This file was deleted.

Loading