MPPointD.java
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.github.mikephil.charting.utils;
import java.util.List;
/**
* Point encapsulating two double values.
*
* @author Philipp Jahoda
*/
public class MPPointD extends ObjectPool.Poolable {
private static ObjectPool<MPPointD> pool;
static {
pool = ObjectPool.create(64, new MPPointD(0,0));
pool.setReplenishPercentage(0.5f);
}
public static MPPointD getInstance(double x, double y){
MPPointD result = pool.get();
result.x = x;
result.y = y;
return result;
}
public static void recycleInstance(MPPointD instance){
pool.recycle(instance);
}
public static void recycleInstances(List<MPPointD> instances){
pool.recycle(instances);
}
public double x;
public double y;
protected ObjectPool.Poolable instantiate(){
return new MPPointD(0,0);
}
private MPPointD(double x, double y) {
this.x = x;
this.y = y;
}
/**
* returns a string representation of the object
*/
public String toString() {
return "MPPointD, x: " + x + ", y: " + y;
}
}