-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stable so far. Contains google c++ tests and memory leak detection.
Data structures: - Singly/Doubly linked list - Array/Node based binary tree - Binary search tree (BST) - Standard/Mutable Heap/Priority Queue - BSTDictionary
- Loading branch information
saad0105050
committed
Sep 11, 2014
1 parent
0869dd6
commit cc44183
Showing
29 changed files
with
7,356 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Express 2013 for Windows Desktop | ||
VisualStudioVersion = 12.0.30723.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "YASI_12", "YASI_12\YASI_12.vcxproj", "{63C1FF10-6FFA-4A4E-958B-9BD1CF80CAEB}" | ||
ProjectSection(ProjectDependencies) = postProject | ||
{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7} = {C8F6C172-56F2-4E76-B5FA-C3B423B31BE7} | ||
EndProjectSection | ||
EndProject | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtest", "..\gtest-1.7.0\msvc\gtest.vcxproj", "{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Win32 = Debug|Win32 | ||
Release|Win32 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{63C1FF10-6FFA-4A4E-958B-9BD1CF80CAEB}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{63C1FF10-6FFA-4A4E-958B-9BD1CF80CAEB}.Debug|Win32.Build.0 = Debug|Win32 | ||
{63C1FF10-6FFA-4A4E-958B-9BD1CF80CAEB}.Release|Win32.ActiveCfg = Release|Win32 | ||
{63C1FF10-6FFA-4A4E-958B-9BD1CF80CAEB}.Release|Win32.Build.0 = Release|Win32 | ||
{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|Win32.ActiveCfg = Debug|Win32 | ||
{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug|Win32.Build.0 = Debug|Win32 | ||
{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|Win32.ActiveCfg = Release|Win32 | ||
{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release|Win32.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "Sorter.h" | ||
|
||
namespace yasi{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
namespace yasi{ | ||
template<class T> | ||
class Sorter | ||
{ | ||
public: | ||
typedef typename T::iterator iter_t; | ||
Sorter(); | ||
|
||
// insertion sort | ||
|
||
// bubble sort | ||
template<class T> | ||
void bubbleSort(const T& src, T& dest){ | ||
// copy to dest | ||
int size = src.size(); | ||
for (int i = 0; i < size; i++){ | ||
dest.push_back(src[i]); | ||
} | ||
|
||
// now sort | ||
size = dest.size(); | ||
for (int i = 0; i < size - 1; i++){ | ||
for (int j = i + 1; j < size; j++){ | ||
if (dest[i] > dest[j]){ | ||
typename T::value_type temp = dest[i]; | ||
dest[i] = dest[j]; | ||
dest[j] = temp; | ||
} | ||
} | ||
} | ||
} | ||
~Sorter(); | ||
}; | ||
|
||
// implementations | ||
// constructor | ||
template<class T> | ||
Sorter<T>::Sorter() | ||
{ | ||
} | ||
|
||
// destructor | ||
template<class T> | ||
Sorter<T>::~Sorter() | ||
{ | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>{63C1FF10-6FFA-4A4E-958B-9BD1CF80CAEB}</ProjectGuid> | ||
<RootNamespace>YASI_12</RootNamespace> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<CharacterSet>MultiByte</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>MultiByte</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup /> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<SDLCheck>true</SDLCheck> | ||
<AdditionalIncludeDirectories>"$(SolutionDir)\..\gtest-1.7.0\include"</AdditionalIncludeDirectories> | ||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> | ||
</ClCompile> | ||
<Link> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<AdditionalLibraryDirectories>$(SolutionDir)..\gtest-1.7.0\msvc\$(SolutionName)\$(ConfigurationName)\</AdditionalLibraryDirectories> | ||
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);gtest.lib;</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="main.cpp" /> | ||
<ClCompile Include="Sorter.cpp" /> | ||
<ClCompile Include="utils.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="common.h" /> | ||
<ClInclude Include="ds.arraybinarytree.h" /> | ||
<ClInclude Include="ds.aux.hastree.h" /> | ||
<ClInclude Include="ds.binaryheap.h" /> | ||
<ClInclude Include="ds.binarysearchtree.h" /> | ||
<ClInclude Include="ds.binarytree.h" /> | ||
<ClInclude Include="ds.binarytreebase.h" /> | ||
<ClInclude Include="ds.BSTDictionary.h" /> | ||
<ClInclude Include="ds.comparable.h" /> | ||
<ClInclude Include="ds.dictionary.h" /> | ||
<ClInclude Include="ds.doublylinkedlist.h" /> | ||
<ClInclude Include="ds.iterator.h"> | ||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> | ||
</ClInclude> | ||
<ClInclude Include="ds.kvpair.h" /> | ||
<ClInclude Include="ds.list.h" /> | ||
<ClInclude Include="ds.node.h" /> | ||
<ClInclude Include="ds.priorityqueue.h" /> | ||
<ClInclude Include="ds.singlylinkedlist.h" /> | ||
<ClInclude Include="ds.tree.h" /> | ||
<ClInclude Include="Sorter.h" /> | ||
<ClInclude Include="stl.iterator.h"> | ||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | ||
</ClInclude> | ||
<ClInclude Include="test.h" /> | ||
<ClInclude Include="utils.h" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="Source Files"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="Resource Files"> | ||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
</Filter> | ||
<Filter Include="Header Files\nonproject"> | ||
<UniqueIdentifier>{e771e66c-6407-4d3a-bd6f-97ad63c60a2d}</UniqueIdentifier> | ||
</Filter> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="main.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="Sorter.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
<ClCompile Include="utils.cpp"> | ||
<Filter>Source Files</Filter> | ||
</ClCompile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="common.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.arraybinarytree.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="Sorter.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.binaryheap.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="utils.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.tree.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.singlylinkedlist.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.doublylinkedlist.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.binarytree.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.binarysearchtree.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.list.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.priorityqueue.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.iterator.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="stl.iterator.h"> | ||
<Filter>Header Files\nonproject</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.node.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.binarytreebase.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.dictionary.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.comparable.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.BSTDictionary.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.kvpair.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="ds.aux.hastree.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
<ClInclude Include="test.h"> | ||
<Filter>Header Files</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
//////////////// CRT memory leak detection ///////////// | ||
#define _CRTDBG_MAP_ALLOC | ||
#include <stdlib.h> | ||
#include <crtdbg.h> | ||
|
||
|
||
#ifdef _DEBUG | ||
#ifndef DBG_NEW | ||
#define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ ) | ||
#define new DBG_NEW | ||
#endif | ||
#endif // _DEBUG | ||
///////////////////////////////////////////////////////// | ||
#include "test.h" | ||
|
||
|
||
namespace yasi{ | ||
|
||
#define CONCAT_DETAIL(x,y) x ## y | ||
#define CONCAT(x,y) CONCAT_DETAIL(x,y) | ||
#define MAKE_UNIQUE(x) CONCAT(x, __COUNTER__ ) | ||
#define MAKE_UNIQUE2(x,y) MAKE_UNIQUE( CONCAT(x,y) ) | ||
#define MAKE_UNIQUE3(x,y, z) MAKE_UNIQUE2( CONCAT(x,y), z ) | ||
|
||
#define DELETE_SAFE(x) {if( (x) != 0 ) delete (x); (x) = 0; } | ||
#define DELETE_ARR_SAFE(x) {if( (x) != 0 ) delete[] (x); (x) = 0; } | ||
#define ARR_LENGTH(x) ( sizeof( (x) )/sizeof( (x)[0] ) ) | ||
|
||
} // namespace yasi |
Oops, something went wrong.