Skip to content
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

Sliced list cannot be made linear #40

Open
mikeb-btw opened this issue Apr 14, 2022 · 0 comments
Open

Sliced list cannot be made linear #40

mikeb-btw opened this issue Apr 14, 2022 · 0 comments

Comments

@mikeb-btw
Copy link
Contributor

I am using version 0.2.0-alpha6.

In the following, a list of size 1 is sliced to make another list of size 1 that is then correctly made linear.

Then, a list of size 2 is sliced into a list of size 1. This new list is attempted to be made linear but that fails.

import io.lacuna.bifurcan.IList;
import io.lacuna.bifurcan.LinearList;

public class Main {
  public static void main(String[] args) {
    LinearList<Integer> list1 = new LinearList<>();
    list1.addLast(1);
    IList<Integer> slice1 = list1.slice(0, 1).linear();
    System.out.println("Slice 1 is linear: " + slice1.isLinear());

    LinearList<Integer> list2 = new LinearList<>();
    list2.addLast(1);
    list2.addLast(2);
    IList<Integer> slice2 = list2.slice(0, 1).linear();
    System.out.println("Slice 2 is linear: " + slice2.isLinear());
  }
}

The output is:

Slice 1 is linear: true
Slice 2 is linear: false

The output should be:

Slice 1 is linear: true
Slice 2 is linear: true
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

No branches or pull requests

1 participant