-
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.
- Loading branch information
1 parent
97dc976
commit f801d30
Showing
21 changed files
with
367 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,14 @@ | ||
生成启动时间为 2017/2/28 21:58:35。 | ||
1>项目“E:\wd\数据结构\数据结构code\my code\LinkQueue\LinkQueue\LinkQueue.vcxproj”在节点 2 上(Build 个目标)。 | ||
1>ClCompile: | ||
C:\Program Files\Microsoft Visual Studio 12.0\VC\bin\CL.exe /c /ZI /nologo /W3 /WX- /sdl /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D _LIB /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Yu"stdafx.h" /Fp"Debug\LinkQueue.pch" /Fo"Debug\\" /Fd"Debug\vc120.pdb" /Gd /TP /analyze- /errorReport:prompt LinkQueue.cpp | ||
LinkQueue.cpp | ||
Link: | ||
C:\Program Files\Microsoft Visual Studio 12.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"E:\wd\数据结构\数据结构code\my code\LinkQueue\Debug\LinkQueue.exe" /INCREMENTAL /NOLOGO opencv_ml249d.lib opencv_calib3d249d.lib opencv_contrib249d.lib opencv_core249d.lib opencv_features2d249d.lib opencv_flann249d.lib opencv_gpu249d.lib opencv_highgui249d.lib opencv_imgproc249d.lib opencv_legacy249d.lib opencv_objdetect249d.lib opencv_ts249d.lib opencv_video249d.lib opencv_nonfree249d.lib opencv_ocl249d.lib opencv_photo249d.lib opencv_stitching249d.lib opencv_superres249d.lib opencv_videostab249d.lib opencv_objdetect249.lib opencv_ts249.lib opencv_video249.lib opencv_nonfree249.lib opencv_ocl249.lib opencv_photo249.lib opencv_stitching249.lib opencv_superres249.lib opencv_videostab249.lib opencv_calib3d249.lib opencv_contrib249.lib opencv_core249.lib opencv_features2d249.lib opencv_flann249.lib opencv_gpu249.lib opencv_highgui249.lib opencv_imgproc249.lib opencv_legacy249.lib opencv_ml249.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"E:\wd\数据结构\数据结构code\my code\LinkQueue\Debug\LinkQueue.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"E:\wd\数据结构\数据结构code\my code\LinkQueue\Debug\LinkQueue.lib" /MACHINE:X86 Debug\LinkQueue.obj | ||
Debug\stdafx.obj | ||
LinkQueue.vcxproj -> E:\wd\数据结构\数据结构code\my code\LinkQueue\Debug\LinkQueue.exe | ||
1>已完成生成项目“E:\wd\数据结构\数据结构code\my code\LinkQueue\LinkQueue\LinkQueue.vcxproj”(Build 个目标)的操作。 | ||
|
||
生成成功。 | ||
|
||
已用时间 00:00:01.03 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,2 @@ | ||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v120:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit | ||
Debug|Win32|E:\wd\数据结构\数据结构code\my code\LinkQueue\| |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,23 @@ | ||
// LinkQueue.cpp : 定义控制台应用程序的入口点。 | ||
// | ||
|
||
#include "stdafx.h" | ||
#include"LinkQueue.h" | ||
#include<string> | ||
using namespace std; | ||
|
||
int _tmain(int argc, _TCHAR* argv[]) | ||
{ | ||
string s1("wd"); | ||
LinkQueue<string> queue; | ||
queue.EnQueue(s1); | ||
queue.EnQueue("ustc"); | ||
queue.EnQueue("ahu"); | ||
queue.Print(); | ||
queue.DeQueue(); | ||
queue.Print(); | ||
string a=queue.GetQueueHead(); | ||
|
||
return 0; | ||
} | ||
|
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,132 @@ | ||
#pragma once | ||
#include <iostream> | ||
#include <string> | ||
#include <exception> | ||
using namespace std; | ||
|
||
//自定义异常类 | ||
class LinkQueueException : public exception //专门提供给外部使用的,不能做成内部类 | ||
{ | ||
public: | ||
LinkQueueException(string msg) : m_msg(msg) {} | ||
const char * what() const throw () //重载 | ||
{ | ||
return m_msg.c_str(); | ||
} | ||
private: | ||
string m_msg; | ||
}; | ||
|
||
//链队列 | ||
template<typename T> | ||
class LinkQueue | ||
{ | ||
public: | ||
LinkQueue(); //无参构造 | ||
LinkQueue(T initValue); //有惨构造 | ||
~LinkQueue(); | ||
void EnQueue(T e); //入队 | ||
void DeQueue(); //出队 | ||
int GetSize(); //获取队列长度 | ||
T GetQueueHead(); //获取队头 | ||
void Print(); //遍历队列 | ||
void ClearQueue(); //清空队列 | ||
private: | ||
void InitQueue(); //初始化队列 | ||
bool IsEmpty(); //队列是否为空 | ||
|
||
private: //把Node作为内部类,不让外部访问 | ||
class Node //节点类 | ||
{ | ||
public: | ||
Node(T d, Node* n = nullptr) : data(d), next(n) {} | ||
private: | ||
T data; | ||
Node* next; | ||
friend class LinkQueue; //如果成员变量声明为私有,那么只有声明友元类才能访问 | ||
}; | ||
private: | ||
Node* m_front; //头节点,指向队首 | ||
Node* m_rear; //尾节点,指向队尾 | ||
int m_count; //队列大小 | ||
T m_initVlaue="0"; //初始化节点的值 | ||
}; | ||
|
||
//构造函数 | ||
template <typename T> | ||
LinkQueue<T>::LinkQueue() | ||
{ | ||
InitQueue(); | ||
} | ||
//初始化 | ||
template <typename T> | ||
void LinkQueue<T>::InitQueue() | ||
{ | ||
m_front = new Node(m_initVlaue); | ||
m_rear = new Node(m_initVlaue); | ||
m_count = 0; | ||
} | ||
//有参构造函数 | ||
template <typename T> | ||
void LinkQueue<T>::LinkQueue(T initValue) | ||
{ | ||
m_initVlaue = initValue; | ||
InitQueue(); | ||
} | ||
//析构函数 | ||
template <typename T> | ||
LinkQueue<T>::~LinkQueue() | ||
{ | ||
ClearQueue(); | ||
} | ||
//清空队列 | ||
template <typename T> | ||
void LinkQueue<T>::ClearQueue() | ||
{ | ||
delete m_front; | ||
m_front = nullptr; | ||
delete m_rear; | ||
m_rear = nullptr; | ||
} | ||
//入队 | ||
template <typename T> | ||
void LinkQueue<T>::EnQueue(T e) | ||
{ | ||
Node* node = new Node(m_initValue); | ||
node->data = e; | ||
if (IsEmpty()) | ||
m_rear->next = node; | ||
else | ||
m_rear->next->next = node; | ||
m_rear->next = node; | ||
node->next = nullptr; | ||
++m_count; | ||
} | ||
//出队 | ||
template <typename T> | ||
void LinkQueue<T>::DeQueue() | ||
{ | ||
if (IsEmpty()) | ||
{ | ||
//cout << "队空,出队失败" << endl; | ||
throw LinkQueueException("队空,出队失败"); | ||
} | ||
Node* temp = m_front->next; | ||
m_front->next = temp->next; | ||
deleta temp; | ||
--m_count; | ||
} | ||
//获取队列长度 | ||
template <typename T> | ||
T LinkQueue<T>::GetSize() | ||
{ | ||
return m_count; | ||
} | ||
|
||
template <typename T> | ||
T LinkQueue<T>::GetQueueHead() | ||
{ | ||
if (IsEmpty()) | ||
throw LinkQueueException("队空,无法获得头节点"); | ||
|
||
} |
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,96 @@ | ||
<?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>{D92C17FB-5C51-46A2-8930-8E344EEB45AF}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>LinkQueue</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>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v120</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</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 Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<PrecompiledHeader>Use</PrecompiledHeader> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<SDLCheck>true</SDLCheck> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<Text Include="ReadMe.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="LinkQueue.h" /> | ||
<ClInclude Include="stdafx.h" /> | ||
<ClInclude Include="targetver.h" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="LinkQueue.cpp" /> | ||
<ClCompile Include="stdafx.cpp"> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> | ||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> | ||
</ClCompile> | ||
</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,39 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup> | ||
<Filter Include="源文件"> | ||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
</Filter> | ||
<Filter Include="头文件"> | ||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> | ||
</Filter> | ||
<Filter Include="资源文件"> | ||
<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> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Text Include="ReadMe.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="stdafx.h"> | ||
<Filter>头文件</Filter> | ||
</ClInclude> | ||
<ClInclude Include="targetver.h"> | ||
<Filter>头文件</Filter> | ||
</ClInclude> | ||
<ClInclude Include="LinkQueue.h"> | ||
<Filter>头文件</Filter> | ||
</ClInclude> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClCompile Include="stdafx.cpp"> | ||
<Filter>源文件</Filter> | ||
</ClCompile> | ||
<ClCompile Include="LinkQueue.cpp"> | ||
<Filter>源文件</Filter> | ||
</ClCompile> | ||
</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 @@ | ||
======================================================================== | ||
控制台应用程序:LinkQueue 项目概述 | ||
======================================================================== | ||
|
||
应用程序向导已为您创建了此 LinkQueue 应用程序。 | ||
|
||
本文件概要介绍组成 LinkQueue 应用程序的每个文件的内容。 | ||
|
||
|
||
LinkQueue.vcxproj | ||
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 | ||
|
||
LinkQueue.vcxproj.filters | ||
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。 | ||
|
||
LinkQueue.cpp | ||
这是主应用程序源文件。 | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
其他标准文件: | ||
|
||
StdAfx.h, StdAfx.cpp | ||
这些文件用于生成名为 LinkQueue.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
其他注释: | ||
|
||
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 | ||
|
||
///////////////////////////////////////////////////////////////////////////// |
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,8 @@ | ||
// stdafx.cpp : 只包括标准包含文件的源文件 | ||
// LinkQueue.pch 将作为预编译头 | ||
// stdafx.obj 将包含预编译类型信息 | ||
|
||
#include "stdafx.h" | ||
|
||
// TODO: 在 STDAFX.H 中 | ||
// 引用任何所需的附加头文件,而不是在此文件中引用 |
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,15 @@ | ||
// stdafx.h : 标准系统包含文件的包含文件, | ||
// 或是经常使用但不常更改的 | ||
// 特定于项目的包含文件 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "targetver.h" | ||
|
||
#include <stdio.h> | ||
#include <tchar.h> | ||
|
||
|
||
|
||
// TODO: 在此处引用程序需要的其他头文件 |
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,8 @@ | ||
#pragma once | ||
|
||
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。 | ||
|
||
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将 | ||
// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。 | ||
|
||
#include <SDKDDKVer.h> |