You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "coderodde (via GitHub)" <gi...@apache.org> on 2025/12/06 15:47:11 UTC
[PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
coderodde opened a new pull request, #664:
URL: https://github.com/apache/commons-collections/pull/664
This PR contains:
1. IndexedLinkedList: the actual list implementation we try to propose for inclusion in Collections.
2. ExtendedTreeList: the subclass of TreeList used in JMH benchmarking.
3. The actual JMH benchmark (that supports our bold claim that ILL > TreeList)
4. A couple of unit test files for testing.
Limitations so far:
1. We cannot make our unit test files run.
2. Our IDE (NetBeans) introduced two configuration files that failed the assumption of having the license in them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on PR #664:
URL: https://github.com/apache/commons-collections/pull/664#issuecomment-3621958684
> Hello, @garydgregory
>
> Are these correct instructions for rebasing the NetBeans related files:
>
> https://chatgpt.com/s/t_693544c351308191a5467b6d20d0f856
>
> ?
Hello @coderodde
Thank you for your updates.
Unless you know git, you should go with a known source, for example:
- https://git-scm.com/book/en/v2/Git-Branching-Rebasing
- https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase
- https://docs.gitlab.com/topics/git/git_rebase/
HTH
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "coderodde (via GitHub)" <gi...@apache.org>.
coderodde closed pull request #664: Pushing a branch for adding the IndexedLinkedList.
URL: https://github.com/apache/commons-collections/pull/664
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #664:
URL: https://github.com/apache/commons-collections/pull/664#discussion_r2596265845
##########
src/main/java/org/apache/commons/collections4/list/ExtendedTreeList.java:
##########
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections4.list;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Objects;
+
+/**
+ * This class extends {@link TreeList}. It provides some methods that are needed
+ * in benchmarking the actual {@code TreeList} against the
+ * {@link IndexedLinkedList}.
+ */
+public class ExtendedTreeList<E> extends TreeList<E> {
Review Comment:
Hello @coderodde,
This class doesn't belong in `main`. Why is this needed at all?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "coderodde (via GitHub)" <gi...@apache.org>.
coderodde commented on code in PR #664:
URL: https://github.com/apache/commons-collections/pull/664#discussion_r2596325572
##########
src/main/java/org/apache/commons/collections4/list/ExtendedTreeList.java:
##########
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections4.list;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Objects;
+
+/**
+ * This class extends {@link TreeList}. It provides some methods that are needed
+ * in benchmarking the actual {@code TreeList} against the
+ * {@link IndexedLinkedList}.
+ */
+public class ExtendedTreeList<E> extends TreeList<E> {
Review Comment:
Hello @garydgregory ,
I had to roll `ExtendedTreeList` in order to provide such methods as `getFirst()` and friends for the actual JMH benchmark. Shall I remove it from the PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "vlsi (via GitHub)" <gi...@apache.org>.
vlsi commented on PR #664:
URL: https://github.com/apache/commons-collections/pull/664#issuecomment-3621857973
It would be great if the new data structure did not require pulling all the other commons-collections dependencies.
I am sure it is the right time to consider adding the new structure as a new (optional) module of commons-collections, so the users could select the bits they need.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #664:
URL: https://github.com/apache/commons-collections/pull/664#discussion_r2595114060
##########
src/test/java/org/apache/commons/collections4/list/IndexedLinkedListTest.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections4.list;
+
+/**
+ *
+ * @author Rodion "rodde" Efremov
Review Comment:
Remove author and version tags. since tags are only needed for new public and protected elements under `main`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "coderodde (via GitHub)" <gi...@apache.org>.
coderodde commented on PR #664:
URL: https://github.com/apache/commons-collections/pull/664#issuecomment-3621846846
Hello, Gary.
Are these correct instructions for rebasing the NetBeans related files:
https://chatgpt.com/s/t_693544c351308191a5467b6d20d0f856
?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #664:
URL: https://github.com/apache/commons-collections/pull/664#discussion_r2596364560
##########
src/main/java/org/apache/commons/collections4/list/ExtendedTreeList.java:
##########
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections4.list;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Objects;
+
+/**
+ * This class extends {@link TreeList}. It provides some methods that are needed
+ * in benchmarking the actual {@code TreeList} against the
+ * {@link IndexedLinkedList}.
+ */
+public class ExtendedTreeList<E> extends TreeList<E> {
Review Comment:
Hello @coderodde
Thank you for your quick reply.
I think I see what's happening here: `java.util.LinkedList<E>` implements `Deque<E>` but `org.apache.commons.collections4.list.TreeList<E>` doesn't. It looks like `ExtendedTreeList` implements `Deque` methods but doesn't actually implement the interface with an `implements Deque<E>` in the code. Then I see `IndexedLinkedList` implements `Deque`. So we have a bit of a mismatch.
So:
- It's good that `IndexedLinkedList` implements `Deque<E>`
- It's not good that `ExtendedTreeList` doesn't
If all of that makes sense and you agree, do you think that `org.apache.commons.collections4.list.TreeList<E>` should implement `Deque<E>` _first_, then `ExtendedTreeList` would become superflous.
If you agree, you can create a PR that causes `org.apache.commons.collections4.list.TreeList<E>` to implement `Deque<E>`, with tests 😉
Another wrinkle is that `IndexedLinkedList` doesn't fit in the JRE's collection framework by extending `java.util.AbstractSequentialList<E>` or `java.util.AbstractList<E>`. Is there a reason to not fit it in?
Thank. you!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #664:
URL: https://github.com/apache/commons-collections/pull/664#discussion_r2595114060
##########
src/test/java/org/apache/commons/collections4/list/IndexedLinkedListTest.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections4.list;
+
+/**
+ *
+ * @author Rodion "rodde" Efremov
Review Comment:
Remove `author` and `version` tags. `since` tags are only needed for new public and protected elements under `main`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #664:
URL: https://github.com/apache/commons-collections/pull/664#discussion_r2596266689
##########
src/main/java/org/apache/commons/collections4/list/IndexedLinkedList.java:
##########
@@ -0,0 +1,5706 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.collections4.list;
+
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.ConcurrentModificationException;
+import java.util.Deque;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.Random;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.Consumer;
+import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
+
+/**
+ * <p>
+ * This class implements the indexed, heuristic doubly-linked list data
+ * structure that runs all the single-element operations in expected
+ * \(\mathcal{O}(\sqrt{n})\) time. Under the hood, the actual elements are
+ * stored in a doubly-linked list. However, we also maintain a list of so-called
+ * <i>"fingers"</i> stored in a random access array. Each finger {@code F}
+ * contains two data fields:
+ * <ul>
+ * <li>{@code F.node} - the actual element node,</li>
+ * <li>{@code F.index} - the appearance index of {@code F.node} in the actual
+ * list.</li>
+ * </ul>
+ *
+ * <p>
+ *
+ * For the list of size \(n\), we maintain
+ * \(\bigg \lceil \sqrt{n} \bigg \rceil + 1\) fingers. The rightmost finger in
+ * the finger list is a <i>special end-of-list sentinel</i>. It always has
+ * {@code F.node = null} and {@code F.index = } \(n\). The fingers are sorted by
+ * their indices. That arrangement allows simpler and faster code in the method
+ * that accesses a finger via element index; see
+ * {@link FingerList#getFingerIndexImpl(int)}. Since number of fingers is
+ * \(\sqrt{n}\), and assuming that the fingers are evenly distributed, each
+ * finger "covers" \(n / \sqrt{n} = \sqrt{n}\) elements. In order to access an
+ * element in the actual list, we first consult the finger list for the index
+ * {@code i} of the finger {@code fingerArray[i]} that is closest to the index
+ * of the target element. This runs in
+ *
+ * \[
+ * \mathcal{O}(\log \sqrt{n}) = \mathcal{O}(\log n^{1/2}) = \mathcal{O}(\frac{1}{2} \log n) = \mathcal{O}(\log n).
+ * \]
+ *
+ * The rest is to <i>"rewind"</i> the closest finger to point to the target
+ * element (which requires \(\mathcal{O}(\sqrt{n})\) on evenly distributed
+ * finger lis).
+ *
+ * @param <E> the element type.
+ */
+public class IndexedLinkedList<E> implements Deque<E>,
+ List<E>,
+ Cloneable,
+ java.io.Serializable {
Review Comment:
No need for a fully qualified name `java.io.Serializable` -> `Serializable`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Pushing a branch for adding the IndexedLinkedList. [commons-collections]
Posted by "garydgregory (via GitHub)" <gi...@apache.org>.
garydgregory commented on code in PR #664:
URL: https://github.com/apache/commons-collections/pull/664#discussion_r2595110427
##########
pom.xml:
##########
@@ -86,8 +86,8 @@
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
- <version>${commons.jmh.version}</version>
- <scope>test</scope>
+ <version>1.37</version>
Review Comment:
Please remove these edits.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org