Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8654393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:46:36+00:00 2026-06-12T14:46:36+00:00

I am searching for a list data structure in Java which allows cheap appending

  • 0

I am searching for a list data structure in Java which allows cheap appending of long lists. I tried LinkedList but I found in the documentation of addAll, that an iterator is used to append the two lists. This means that the list, which gets appended, gets cloned during the operation. The iterator walks though the whole list returning every single element. Is there any collection available which omits the iteration while appending two lists?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:46:38+00:00Added an answer on June 12, 2026 at 2:46 pm

    You can use Guava’s Iterables.concat method to create concatenated Iterable View..

    Iterable<T> combined = Iterables.concat(list1, list2);
    
    • This does not copy elements from one list to another..
    • So, it does not change any of your lists..
    • Also, this does not create a new list (It creates an Iterable which is not a list)

    Basically it creates an Iterable through which you can iterate over the two lists back to back (It iterates elements from list1 then from list2..

    NOTE: – If you want a list as a concatenation of the two lists, then this might not help you much.. Because, it does not create a list, but an Iterable.. For that case, you have no other choice than Iterating over your lists and copy each of your reference..

    From the docs: –

    It Combines two iterables into a single iterable. The returned iterable
    has an iterator that traverses the elements in a, followed by the
    elements in b. The source iterators are not polled until necessary.
    The returned iterable’s iterator supports remove() when the
    corresponding input iterator supports it.

    You also have a var-args version of this method.. See Docs.. This can take any number of lists, and returns Iterables that can iterate over those lists in order.. So, you can do like this..

    Iterable<T> combined = Iterables.concat(list1, list2, list3, list4, ...);
    

    This link –> google-guava-libraries-essentials might also be of interest to you..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a binary data structure (tree, list) that enables very fast searching.
I'm searching for an algorithm which will convert a data structure like the following
I'm searching for data structure to store list of unique indices (integers). The most
Each of of these threads is searching through a different list of data objects
Having browsed the net for a while, I've found that searching for a list
I have been searching but unable to find a proper list. Can someone please
Possible Duplicate: Table like java data structure I am looking for a Table-like data
Can any one guide me for the method/approch to implement searching-access-list-boxes-data-as-you-type-in-ms-access-forms with mutiple items
I tried Googling and searching everywhere, but couldn't find a definitive authority on this
I want to do searching on encrypted data. Which means that there is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.