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 3989376
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:21:57+00:00 2026-05-20T06:21:57+00:00

I have a function that returns a list like this:- List <Column <String1, String2>>

  • 0

I have a function that returns a list like this:-

List <Column <String1, String2>>

Next I want to pass this list to a 2nd function, but
2nd function just needs a list which contains only 1st part (string1) of the Column(s) of the above list.

So I want pass just this list to 2nd function:-

List <String1>

my use case: Both the functions are from a library that I use to access database(Cassandra) for a web application. 1st function gives me a list of all columns which has two parts name(String1) and value(String2). So 1st function gives me a list of all columns(each of which has two strings) then I just need to use the list of column names to supply it to 2nd function that’ll query the DB for those columns.

Since I need to do this job atleast 2-3 times before asking for data from DB for a single page, I need a superfast and a reasonably efficient method to do so.

  • 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-05-20T06:21:58+00:00Added an answer on May 20, 2026 at 6:21 am

    It depends on what you mean by “efficient” (memory, execution time, something else?) and what that second function is doing.

    If you care about speed and the second function is going to be looking at the items in the list repeatedly, then you should probably just copy the strings into a new List<String>:

    List<String> strings = new ArrayList<String>(input.size());
    for (Column<String, String> column : input) {
        strings.add(column.name());
    }
    return strings;
    

    If, on the other hand, the second function is going to only look at a small subset of the items or if you care more about memory than speed then you probably want a lazy view that converts items as they are accessed. Lists.transform from Google Guava can do this for you:

    return Lists.transform(input, new Function<Column<String, String>, String>() {
        public String apply(Column<String, String> column) {
            return column.name();
        }
    };
    

    Note that you may want to create he Function as a separate static class unless you’re ok with it holding onto a reference to your enclosing instance. I used an anonymous class here for brevity/clarity.

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

Sidebar

Related Questions

I have a function, that returns the next higher value of a Dictionary-Keys-List compared
I have a function that returns two values in a list. Both values need
We have a table value function that returns a list of people you may
Say you have a value like this: n = 5 and a function that
I have a function on my server code that returns a list of ElementRow
I have some XML code that looks like this <SEARCHRESULTS> <FUNCTION name=BarGraph> <PARAMETER name=numList></PARAMETER>
I have a webservice function that returns something like the following: New Orleans, Louisiana
I have a PHP function that returns an array. This is the output of
I have a function that returns the request parameters for each request: private function
I have a function that returns log10 values. On converting them to normal numbers,

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.