Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fa4fefe
a list has been written to implement a hash table
MinyazevR Nov 27, 2021
4b98d8b
removed unnecessary code
MinyazevR Nov 27, 2021
f5f3c42
writing basic functions for working with a hash table
MinyazevR Nov 27, 2021
823c97c
writing basic functions for working with a hash table
MinyazevR Nov 27, 2021
e20f209
Merge pull request #63 from MinyazevR/NewSinglyLinkedList
MinyazevR Nov 27, 2021
c2ecc54
the basic functions for working with a hash table are written
MinyazevR Nov 27, 2021
03c083f
work has been done with the file
MinyazevR Nov 27, 2021
6f63967
added a function to count the number of duplicate elements
MinyazevR Nov 27, 2021
3900609
Merge pull request #64 from MinyazevR/NewSinglyLinkedList
MinyazevR Nov 27, 2021
dd937c5
Added comments
MinyazevR Nov 27, 2021
9d9c881
Merge branch 'HashTable' of https://github.com/MinyazevR/Homework-1-s…
MinyazevR Nov 27, 2021
b8c7f28
Added comments
MinyazevR Nov 27, 2021
8224d00
changed the function to expand the size of the array
MinyazevR Nov 27, 2021
6e4416d
commit
MinyazevR Nov 27, 2021
339d6b9
Merge branch 'HashTable' of https://github.com/MinyazevR/Homework-1-s…
MinyazevR Nov 27, 2021
bb3dc4d
trying to write a function to add an element
MinyazevR Nov 30, 2021
eeb8fd4
changing the functions for working with the list
MinyazevR Dec 5, 2021
48247b9
changing functions to work with a hash table
MinyazevR Dec 5, 2021
63cb7e2
changing functions to work with a hash table
MinyazevR Dec 5, 2021
1ed2ace
changing the shortcomings in the functions for the hash table
MinyazevR Dec 8, 2021
5d5eb34
changed the function for expanding the hash table
MinyazevR Dec 8, 2021
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
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 Version 16
VisualStudioVersion = 16.0.31410.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FrequencyOfOccurrenceOfWords", "FrequencyOfOccurrenceOfWords\FrequencyOfOccurrenceOfWords.vcxproj", "{ECBF2784-C770-44C8-A208-31046468F94E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ECBF2784-C770-44C8-A208-31046468F94E}.Debug|x64.ActiveCfg = Debug|x64
{ECBF2784-C770-44C8-A208-31046468F94E}.Debug|x64.Build.0 = Debug|x64
{ECBF2784-C770-44C8-A208-31046468F94E}.Debug|x86.ActiveCfg = Debug|Win32
{ECBF2784-C770-44C8-A208-31046468F94E}.Debug|x86.Build.0 = Debug|Win32
{ECBF2784-C770-44C8-A208-31046468F94E}.Release|x64.ActiveCfg = Release|x64
{ECBF2784-C770-44C8-A208-31046468F94E}.Release|x64.Build.0 = Release|x64
{ECBF2784-C770-44C8-A208-31046468F94E}.Release|x86.ActiveCfg = Release|Win32
{ECBF2784-C770-44C8-A208-31046468F94E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DD9F0B46-CB0B-4502-8346-C982FBFEB6C1}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "ReadFile.h"
#include "TestReadFileUsingHashTable.h"
#include <stdio.h>

int main()
{
if (!testReadFileUsingHashTable())
{
return -1;
}
Error error = NOT_ERROR;
HashTable* table = createTable(&error, 1);
int result = readFile(&table, "Text.txt");
if (result == -1)
{
deleteHashTable(table);
printf("File not found");
return -1;
}
if (error == INSUFFICIENT_MEMORY)
{
deleteHashTable(table);
printf("Memory not allocated");
return -1;
}
printValue(table);
deleteHashTable(table);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" 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>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{ecbf2784-c770-44c8-a208-31046468f94e}</ProjectGuid>
<RootNamespace>FrequencyOfOccurrenceOfWords</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</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>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<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|x64'">
<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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\HashTable\HashTable\HashTable.c" />
<ClCompile Include="..\..\SinglyLinkedListForHashTable\SinglyLinkedListForHashTable\SinglyLinkedListForHashTable.c" />
<ClCompile Include="ReadFile.c" />
<ClCompile Include="FrequencyOfOccurrenceOfWords.c" />
<ClCompile Include="TestReadFileUsingHashTable.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\HashTable\HashTable\HashTable.h" />
<ClInclude Include="..\..\SinglyLinkedListForHashTable\SinglyLinkedListForHashTable\SinglyLinkedListForHashTable.h" />
<ClInclude Include="ReadFile.h" />
<ClInclude Include="TestReadFileUsingHashTable.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Файлы заголовков">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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>
<ClCompile Include="ReadFile.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="..\..\HashTable\HashTable\HashTable.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="..\..\SinglyLinkedListForHashTable\SinglyLinkedListForHashTable\SinglyLinkedListForHashTable.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="FrequencyOfOccurrenceOfWords.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="TestReadFileUsingHashTable.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\HashTable\HashTable\HashTable.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="..\..\SinglyLinkedListForHashTable\SinglyLinkedListForHashTable\SinglyLinkedListForHashTable.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="ReadFile.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="TestReadFileUsingHashTable.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>
#include "ReadFile.h"

int readFile(HashTable** table, const char* fileName)
{
FILE* file = fopen(fileName, "r");
if (file == NULL)
{
return -1;
}
while (!feof(file))
{
// words in the file are less than 100 characters in size
char array[100] = { '\0' };
Error error = NOT_ERROR;
if (fscanf(file, "%s", array) != EOF)
{
addElement(array, table, &error);

This comment was marked as resolved.

if (error == INSUFFICIENT_MEMORY)
{
return -2;
}
}
}
fclose(file);
return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once
#include "../../HashTable/HashTable/HashTable.h"

// Function for reading a file
int readFile(HashTable** table, const char* fileName);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World S Hello Hello S World Test Commit A S
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "TestReadFileUsingHashTable.h"
#include "ReadFile.h"

bool testReadFileUsingHashTable()
{
Error error = NOT_ERROR;
HashTable* table = createTable(&error, 100);
int result = readFile(&table, "Test.txt");
if (result == -1)
{
deleteHashTable(table);
return false;
}
if (error == INSUFFICIENT_MEMORY)
{
deleteHashTable(table);
return false;
}
const int firstCheck = countNumberOfDuplicateItemsForSpecificList("Hello", table);
const int secondCheck = countNumberOfDuplicateItemsForSpecificList("World", table);
const int thirdCheck = countNumberOfDuplicateItemsForSpecificList("Test", table);
const int fourthCheck = countNumberOfDuplicateItemsForSpecificList("Commit", table);
const int fifthCheck = countNumberOfDuplicateItemsForSpecificList("A", table);
const int sixthCheck = countNumberOfDuplicateItemsForSpecificList("S", table);
deleteHashTable(table);
return firstCheck == 3 && secondCheck == 2 && thirdCheck == 1
&& fourthCheck == 1 && fifthCheck == 1 && sixthCheck == 3;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once
#include <stdbool.h>

// Function for checking the counting of words in the text
bool testReadFileUsingHashTable();

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions Homework № 9/HashTable/HashTable.sln
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 Version 16
VisualStudioVersion = 16.0.31410.357
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HashTable", "HashTable\HashTable.vcxproj", "{7F515015-3F19-4A2A-9F71-2B4E17988297}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7F515015-3F19-4A2A-9F71-2B4E17988297}.Debug|x64.ActiveCfg = Debug|x64
{7F515015-3F19-4A2A-9F71-2B4E17988297}.Debug|x64.Build.0 = Debug|x64
{7F515015-3F19-4A2A-9F71-2B4E17988297}.Debug|x86.ActiveCfg = Debug|Win32
{7F515015-3F19-4A2A-9F71-2B4E17988297}.Debug|x86.Build.0 = Debug|Win32
{7F515015-3F19-4A2A-9F71-2B4E17988297}.Release|x64.ActiveCfg = Release|x64
{7F515015-3F19-4A2A-9F71-2B4E17988297}.Release|x64.Build.0 = Release|x64
{7F515015-3F19-4A2A-9F71-2B4E17988297}.Release|x86.ActiveCfg = Release|Win32
{7F515015-3F19-4A2A-9F71-2B4E17988297}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4E72E434-3C39-4E83-A4CF-8341EC15AAA4}
EndGlobalSection
EndGlobal
Loading