My IDE suggested I use a LinkedList, so it automatically imported it into my code. But is there a way to achieve the same thing but without importing a LinkedList and using only an ArrayList? Apparently its possible but I have no idea how.
/**
* Search this Twitter for the latest Tweet of a given author.
* If there are no tweets from the given author, then the
* method returns null.
* O(1)
*/
public Tweet latestTweetByAuthor(String author) {
//getting hashvalue for the date
int hashValue = tweetsByAuthor2.hashFunction(author);
//getting all the hashtable buckets
ArrayList<LinkedList<HashPair<String, Tweet>>> allBuckets = tweetsByAuthor2.getBuckets();
//if buckets at hashvalue == null
if (allBuckets.get(hashValue) == null) {
return null;
} else {
return allBuckets.get(hashValue).get(allBuckets.get(hashValue).size() - 1).getValue();
}
}