Menu

Home

Daneel S. Yaitskov

The package allows to work with scalar arrays as usual collections.

The problem with a scalar array Java templates don't support
scalar types as generic parameters. Java code working with collection
interfaces such as List or Collection is inapplicable
for arrays. Some libraries supply methods to work with object array.
These methods are generic and built-in types int,
boolean, long, short, byte, double, float suffer.

The number of scalar type is small and finite. There are realization
of Iterable, Iterator, Collection, and List interfaces for each scalar
type. Also the library gives such useful methods as contains
and indexOf for objects with Iterable interface only.

Yeah. There is some stupidness because all implementations
differ between each other only types and this code has 100% implicit
coupling and duplications. But Java has not left other way.

At least a user of the library should use only one class
org.dan.lastjcl.ScalUtils to win this hell and to get rid of loops in
his code when he works with scalar arrays.

:::java
    System.out.println(
        StringUtils.join(
            ScalUtils.wrapCollection("hello world".getBytes())));

    // cipher     
    RandomAccessFile file = new RandomAccessFile("file.bin", "rw");     
    byte[] body = new byte[(int)file.length()];     
    file.read(body);        
    List<Byte> lbody = ScalUtils.wrapList(body);        
    Collections.shuffle(lbody);     
    file.seek(0);
    file.write(body);
    file.close();        

Compound collections

A compound collection (org.dan.lastjcl.scalcol.CompoundCollection) is an addition to
is a view of multiple joint collections, iterables or lists. Creation of such view doesn't require to copy elements from existing collections. It saves time and memory. Here source collections named as sub collections. For example such sub collection can be a wrapped scalar array. Arrays are intended to keep compactly big sets of elements and. With a compound collection you can work with collections of different implementations. For example one sub collection is
a java.util.ArrayList, second is a java.util.LinkedList, and third is org.dan.lastjcl.scalist.IntsList.

If you need to collect some statistic from dozens places it's much much more efficiency to make view of them and pass through as one whole list.

Project Admins:


Discussion

  • Daneel S. Yaitskov

    :::xml
    <dependency>
        <groupId>net.sf.lastjcl</groupId>
        <artifactId>lastjcl</artifactId>
        <version>1.1</version>
    </dependency>
    
     
  • Daneel S. Yaitskov

     

    Related

    Wiki: Change log


Log in to post a comment.

MongoDB Logo MongoDB