Skip to content

Method insertBefore in LinkedList and the first element. #4

@stanislavkrsv

Description

@stanislavkrsv

Hello!

Method insertBefore doesn't work correctly with the first element in a list.
You can't insert before the first element.

Test case:

$l = new \DS\LinkedList\Classes\LinkedList();
$l->insert("1");
$l->insert("2");
$l->insert("3");

$l->insertBefore('0','1');
$l->display();

Expected:

Total Nodes: 4
0
1
2
3

Actual:

Total Nodes: 4
1
2
3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions