Skip to content
/ stoa Public
forked from adarshsoodan/stoa

Structure of Arrays library in Java

License

Notifications You must be signed in to change notification settings

bitslab/stoa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stoa

Stoa library provides Structure of Arrays in Java, compatible with the standard Collection interfaces.

Usage

StoaBuilder provides static methods which return Supplier to construct a list, map or set. For example StoaBuilder.list(BeanInfo info) yields a List<> compatible object that maps the Bean fields onto arrays. Similarly for map() and set().

public class Point2D {
  private int x;
  private int y;
  private boolean insideVolume;
  // getter, setters and constructors here ...
};

public static void main(String args[]) throws IntrospectionException {

  Stoa<Point2D> points = StoaBuilder.<Point2D>list(Introspector.getBeanInfo(Point2D.class, Object.class)).get();
  points.add(new Point2D(1, 1, false));
  points.add(new Point2D(2, 3, true));
  points.add(new Point2D(5, 7, false));
  points.add(new Point2D(11, 13, true));
  System.out.println(Arrays.toString((int[]) points.data("x")));
  System.out.println(Arrays.toString((int[]) points.data("y")));
  System.out.println(Arrays.toString((long[]) points.data("insideVolume"))); // Note that booleans are stored inside a long array
}

Building

$ mvn package

License

GNU LGPL v3. Please see LICENSE file for details.

About

Structure of Arrays library in Java

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%