-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HW 4 is completed #4
base: master
Are you sure you want to change the base?
Conversation
5405173
to
627eae1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо за выполненное задание. Хорошая работа
Итого: 8 баллов из 10. Принято
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Прошу, чтобы PR содержал только файлы, относящиеся к текущему ДЗ
v = lruC.queue.PushFront(value) | ||
v.Value = &CacheItem{key, value} | ||
lruC.items[key] = v | ||
lruC.cleanOutdatedElements() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Формально корректнее сначала проверить размер списка, а затем добавлять элемент, чтобы не превысить лимит
} | ||
|
||
func (lruC *lruCache) Clear() { | ||
l := lruC.queue.Len() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не хватает лока на время очистки
for range l { | ||
delete(lruC.items, lruC.queue.Front().Value.(*CacheItem).k) | ||
lruC.queue.Remove(lruC.queue.Front()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выполняется полный перебор списка.
Рекомендовал бы вместо этого переинициализировать поля списка как при создании
"strconv" | ||
"sync" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"golang.org/x/exp/rand" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему заменён пакет rand?
newFront := &ListItem{ | ||
Value: v, | ||
Next: l.front, | ||
Prev: nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поля с zero-value можно не указывать явно
Домашнее задание №4 «LRU-кэш»
Чек-лист студента (Что это?)
go mod tidy
..sync
файл. Зачем его удалять?Критерии оценки
выталкивания из кэша редко используемых элементов) - до 3 баллов
Зачёт от 7 баллов