Skip to content

Enums.values() method. #777

@gissuebot

Description

@gissuebot

Original issue created by ray.j.greenwell on 2011-10-31 at 07:51 PM


Just a small suggestion:

Add a method to Enums:

public static <E extends Enum<E>> ImmutableList<E> values (Class<E> clazz);

The method maintains a static weak-key Cache mapping the enum Class to an ImmutableList of the values.

This can be used instead of the inefficient Enum.values() that returns a newly allocated array every time. Arrays suck, mutability sucks, and inefficiency sucks too.

The only wrinkle is that 'base' never imports from 'collect'...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions