2026-rff_mp/MusinAA/task-1/LinkedList.py

25 lines
966 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Связный список (LinkedListPhoneBook)
Узел представляется словарём:
{'name': 'Имя', 'phone': '123', 'next': None}.
"""
def ll_insert(head, name, phone):
"""
Проходит до конца (или сразу добавляет в конец) и возвращает новую
голову (если вставка в начало) или изменяет список по ссылке.
Удобнее возвращать новую голову, если вставка может быть в начало.
"""
def ll_find(head, name):
"""Ищет узел, возвращает телефон или None."""
def ll_delete(head, name):
"""Удаляет узел, возвращает новую голову."""
def ll_list_all(head):
"""Cобирает все записи в список и сортирует.
сортировка вынесена отдельно)."""