Skip to content

Comments

BWT#1

Open
Andrw-404 wants to merge 13 commits intomainfrom
BWT
Open

BWT#1
Andrw-404 wants to merge 13 commits intomainfrom
BWT

Conversation

@Andrw-404
Copy link
Owner

No description provided.

BWT/BWT/Tests.cs Outdated
Comment on lines 1 to 2
namespace BWT
{

Choose a reason for hiding this comment

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

Используйте file-scoped namespaces

Suggested change
namespace BWT
{
namespace BWT;

Comment on lines 41 to 42

}

Choose a reason for hiding this comment

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

Линтер прав

Suggested change
}
}

@@ -0,0 +1,47 @@
namespace BWT

Choose a reason for hiding this comment

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

Здесь тоже нужен file-scoped namespace
И using вниз уехал

namespace BWT
{
using System.Text;
public class BWTAlgorithm

Choose a reason for hiding this comment

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

Если класс только static-методы содержит, его тоже можно отметить как static


for (int i = 0; i < lengthOfString; ++i)
{
rotations[i] = input.Substring(i) + input.Substring(0, i);

Choose a reason for hiding this comment

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

В последнем .net можно вместо Substring использовать оператор диапазона, то есть

Suggested change
rotations[i] = input.Substring(i) + input.Substring(0, i);
rotations[i] = input[i..] + input[..i];

using System.Text;
public class BWTAlgorithm
{
public static (string, int) FrontBWT(string input)

Choose a reason for hiding this comment

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

Типы кортежа по стайлгайду надо именовать, с большой буквы

Suggested change
public static (string, int) FrontBWT(string input)
public static (string ..., int ...) FrontBWT(string input)


Array.Sort(rotations);

string transformed = new string(rotations.Select(s => s[lengthOfString - 1]).ToArray());

Choose a reason for hiding this comment

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

Чтобы взять первый элемент с конца строки, начиная с C# 8 можно писать так

Suggested change
string transformed = new string(rotations.Select(s => s[lengthOfString - 1]).ToArray());
string transformed = new string(rotations.Select(s => s[^1]).ToArray());

Array.Sort(rotations);

string transformed = new string(rotations.Select(s => s[lengthOfString - 1]).ToArray());
int bwtIndex = Array.IndexOf(rotations, input);

Choose a reason for hiding this comment

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

Suggested change
int bwtIndex = Array.IndexOf(rotations, input);
var bwtIndex = Array.IndexOf(rotations, input);

@@ -0,0 +1,41 @@
using System;

Choose a reason for hiding this comment

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

В названии файла лишняя m

{
int lengthOfBWTString = bwtString.Length;

string[] table = new string[lengthOfBWTString];

Choose a reason for hiding this comment

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

Suggested change
string[] table = new string[lengthOfBWTString];
var table = new string[lengthOfBWTString];


public static class BWTAlgorithm
{
public static (string, int) FrontBWT(string input)
Copy link

@YuriUfimtsev YuriUfimtsev May 30, 2025

Choose a reason for hiding this comment

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

Suggested change
public static (string, int) FrontBWT(string input)
public static (string TransformedString, int EndPosition) FrontBWT(string input)

Например

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