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

  • Home
  • SEARCH
  • 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 6576989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:34:46+00:00 2026-05-25T15:34:46+00:00

I want to apply a function to a collection, map, etc, using Guava. Basically,

  • 0

I want to apply a function to a collection, map, etc, using Guava.

Basically, I need to resize the rows and columns of a Table separately so all rows and columns are of equal size, doing something like this:

    Table<Integer, Integer, Cell> table = HashBasedTable.create();
    Maps.transformValues(table.columnMap(), new ResizeFunction(BlockDimension.WIDTH));
    Maps.transformValues(table.rowMap(), new ResizeFunction(BlockDimension.HEIGHT));

public interface Cell {
    int getSize(BlockDimension dimension);
    void setSize(BlockDimension dimension);
}

I already have an idea of what the ResizeFunction should be. However, I need to apply it, not just return a Collection.

  • 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-25T15:34:47+00:00Added an answer on May 25, 2026 at 3:34 pm

    In Guava, you don’t convert existing Lists, but instead create a new one using Iterables.transform:

    final List<String> list = Arrays.asList("race", "box");
    final List<String> transformed =
        Lists.newArrayList(Iterables.transform(list, new Function<String, String>() {
    
            @Override
            public String apply(final String input) {
                return new StringBuilder().append(input).append("car").toString();
            }
        }));
    System.out.println(transformed);
    

    Output:

    [racecar, boxcar]

    Or, if you don’t need a List and a Collection will do, you can use a transformed live view:

    final Collection<String> transformed =
        Collections2.transform(list, new Function<String, String>() {
    
            @Override
            public String apply(final String input) {
                return new StringBuilder().append(input).append("car").toString();
            }
        });
    

    This Collection is a live view of the underlying one, so changes to list will be reflected in this Collection.

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

Sidebar

Related Questions

I want to apply a function to all columns in a matrix with MATLAB.
I have two matrices that I want to apply a function to, by rows:
Using Mathematica, I have a list: l={0,0,0,1,2,0,0,0,1,0,0,0,2,0,0,0} I want to apply a function to
I want to apply a function f to a list of values, however function
I want to apply an XSLT Stylesheet to an XML Document using C# and
I want to apply right alignment on the last cell of every table row,
I want to apply a function to each element of a cell array --
What if you want to apply a function other than format to a list
How can I use the parallel ParHashMap.map to when I want to apply a
I want to apply a 3 argument function in different ways based on a

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.