package com.github.davidmoten.rtree.geometry;

import java.util.List;

/**
 *
 * Not thread safe.
 *
 * @param <T>
 *            list type
 */
public final class ListPair<T extends HasGeometry> {
    private final Group<T> group1;
    private final Group<T> group2;
    // these non-final variable mean that this class is not thread-safe
    // because access to them is not synchronized
    private Float areaSum = null;
    private final Float marginSum;

    public ListPair(List<T> list1, List<T> list2) {
        this.group1 = new Group<T>(list1);
        this.group2 = new Group<T>(list2);
        this.marginSum = group1.geometry().mbr().perimeter() + group2.geometry().mbr().perimeter();
    }

    public Group<T> group1() {
        return group1;
    }

    public Group<T> group2() {
        return group2;
    }

    public float areaSum() {
        if (areaSum == null)
            areaSum = group1.geometry().mbr().area() + group2.geometry().mbr().area();
        return areaSum;
    }

    public float marginSum() {
        return marginSum;
    }

}

@@ -393,17 +393,17 @@
 private 
-F
+f
 loat are
@@ -409,20 +409,18 @@
 eaSum = 
-null
+-1
 ;%0A    pr
@@ -435,9 +435,9 @@
 nal 
-F
+f
 loat
@@ -872,12 +872,10 @@
  == 
-null
+-1
 )%0A  

decrease memory usage of ListPair by making a Float field a float field