Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=1.5
version=1.6
release=false
88 changes: 52 additions & 36 deletions src/main/java/com/dselent/bigarraylist/BigArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -1001,8 +1002,7 @@ public E set(long index, E element) {
* @return The new element at the specified index
*/
public E set(int index, E element) {
long longIndex = index;
return set(longIndex, element);
return set((long)index, element);
}

/**
Expand All @@ -1011,49 +1011,36 @@ public E set(int index, E element) {
* @return True is the list is empty, false otherwise
*/
public boolean isEmpty() {
boolean empty = true;

if (size() > 0) {
empty = false;
}

return empty;
return wholeListSize == 0;
}

//hashCode cannot be implemented correctly due to contents being on disk and out of sight from memory

/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@SuppressWarnings("rawtypes")
@Override
public boolean equals(Object otherObject) {

boolean isEqual = true;

if (otherObject == null) {
isEqual = false;
} else if (this == otherObject) {
isEqual = true;
} else if (!(otherObject instanceof BigArrayList)) {
isEqual = false;
} else {
BigArrayList otherBigArrayList = (BigArrayList) otherObject;

if (wholeListSize != otherBigArrayList.size()) {
isEqual = false;
} else if (liveObject != otherBigArrayList.isLive()) {
isEqual = false;
} else {
for (long i = 0; i < wholeListSize && isEqual; i++) {
if (!get(i).equals(otherBigArrayList.get(i))) {
isEqual = false;
}
}
}
if (!(otherObject instanceof BigArrayList)) {
return super.equals(otherObject);
}

BigArrayList<?> otherBigArrayList = (BigArrayList<?>) otherObject;

return isEqual;
if (wholeListSize != otherBigArrayList.size()) {
return false;
}
if (liveObject != otherBigArrayList.isLive()) {
return false;
}

Iterator<E> thisIterator = this.iterator();
Iterator<?> otherIterator = otherBigArrayList.iterator();
while (thisIterator.hasNext() && otherIterator.hasNext()) {
E o1 = thisIterator.next();
Object o2 = otherIterator.next();
if (!(o1==null ? o2==null : o1.equals(o2)))
return false;
}
return !(thisIterator.hasNext() || otherIterator.hasNext());
}

@Override
Expand All @@ -1078,4 +1065,33 @@ public E next() {
}
};
}

/**
* @param other The other BigArrayList
* @see ArrayList#addAll(Collection)
*/
public void addAll(BigArrayList<? extends E> other) {
for (E element : other) {
add(element);
}
}

/**
* @param other The other collection
* @see ArrayList#addAll(Collection)
*/
public void addAll(Collection<? extends E> other) {
for (E element : other) {
add(element);
}
}

/**
* Clears all elements without clearing the memory
*/
public void clear() {
for (long i = wholeListSize-1; i >= 0; i--) {
remove(i);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/dselent/bigarraylist/CacheMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,4 @@ protected void clearMemory() throws IOException
{
fileAccessor.clearMemory();
}
}
}
5 changes: 1 addition & 4 deletions src/main/java/com/dselent/bigarraylist/FileAccessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,6 @@ protected void clearMemory() throws IOException
}
}
}

//don't delete the folder, other things may be using it

}

}
}
Loading