Skip to content

Bor#2

Open
KirillBorisovich wants to merge 9 commits intomainfrom
Bor
Open

Bor#2
KirillBorisovich wants to merge 9 commits intomainfrom
Bor

Conversation

@KirillBorisovich
Copy link
Owner

No description provided.

return node.NumberOfWordsAfterPrefix;
}

private static bool RecursiveAddition(string element, Node node, int index, ref bool missingLine)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для этих целей используется не ref, а out. Вообще, считается, что ref-параметры использовать нельзя ни в каких случаях, да и out лишний раз тоже нежелательно -- это скорее наследие C, чем необходимость. Здесь можно просто возвращать (bool, bool).

else if (index == element.Length && !node.EndOfWord)
{
node.EndOfWord = true;
missingLine = true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Вы используете три разных слова для обозначения строки: "string", "line", "row" -- это немного путает. При этом, правильно только "string". "line" -- это строка в тексте, она заканчивается \n, "row" -- это строка ("ряд") в таблице. Но здесь дело не в анлгийском языке. Кажется, что разные термины относятся к разным вещам (например, если бы Вы разрабатывали СУБД, логично было бы называть запись в таблице "row", а строковый тип данных -- "string"), здесь же все три термина обозначают одно и то же.

return node.NumberOfWordsAfterPrefix;
}

private static bool RecursiveAddition(string element, Node node, int index, ref bool missingLine)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add не обязательно делать рекурсивным, простого for вполне хватило бы. Заодно и код бы сильно упростился.

Comment on lines +129 to +137
if (index == element.Length && !node.EndOfWord)
{
return false;
}
else if (index == element.Length && node.EndOfWord)
{
node.EndOfWord = false;
return true;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эти два if-а выглядят немного странно.

Suggested change
if (index == element.Length && !node.EndOfWord)
{
return false;
}
else if (index == element.Length && node.EndOfWord)
{
node.EndOfWord = false;
return true;
}
if (index == element.Length)
{
if (node.EndOfWord) {
node.EndOfWord = false;
return true;
} else {
return false;
}
}

@@ -0,0 +1,3 @@
using BorDataStructure;

var bor = new Bor(); No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем здесь создаётся Bor? Чтобы проверить, что он вообще скомпилируется?
Если Program.cs не нужна, надо ставить <OutputType>Library</OutputType>. Либо, здесь можно было сделать простенький консольный интерфейс.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants