Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 332831

Summary: save retrieval of size of an array []
Product: z_Archived Reporter: Stephan Leicht Vogt <stephan.leichtvogt>
Component: ScoutAssignee: Project Inbox <scout.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: zimmermann
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Stephan Leicht Vogt CLA 2010-12-17 04:58:17 EST
As stated in the Forum-Message <http://www.eclipse.org/forums/index.php?t=msg&th=201998&start=0&S=be81068d90b5b6b0945dc5560a882115> it would be useful if there would be also an save way to get the size of an array like it allready exists for Strings.

Example:
int size = ListUtility.size(someByte[]); (someByte[] can be null)
Comment 1 Ivan Motsch CLA 2010-12-23 08:19:34 EST
This will be added for the June 2011 release either in ListUtility, CollectionUtility or ArrayUtility
Comment 2 Ivan Motsch CLA 2011-05-02 10:07:58 EDT
Done as ListUtility.length.

junit test:
    assertEquals(-1, ListUtility.length(null));
    assertEquals(3, ListUtility.length(new int[3]));
    assertEquals(3, ListUtility.length(new int[3][4]));
    assertEquals(3, ListUtility.length(new String[3]));
    assertEquals(3, ListUtility.length(new String[3][4]));
    assertEquals(3, ListUtility.length(new ArrayList<String>(Arrays.asList(new String[]{"a", "b", "c"}))));
    assertEquals(0, ListUtility.length(new HashMap<String, String>()));
Comment 3 Matthias Zimmermann CLA 2011-06-28 08:04:22 EDT
shipped with eclipse scout 3.7.0