Project

General

Profile

Download (1.65 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / DistortedObjectList.java @ 1e438fc7

1
package org.distorted.library;
2

    
3
import java.util.HashMap;
4
/**
5
 * List of all DistortedObjects currently created by the application.
6
 * We need to be able to quickly retrieve an Object by its ID, thus a HashMap.
7
 */
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
final class DistortedObjectList 
11
  {
12
  private static long id =0;  
13
  private static HashMap<Long,DistortedObject> mObjects = new HashMap<>();
14
  
15
///////////////////////////////////////////////////////////////////////////////////////////////////
16

    
17
  static synchronized long add(DistortedObject obj)
18
    {
19
    long ret = id++;  
20
    mObjects.put(ret,obj);
21
    return ret;
22
    }
23

    
24
///////////////////////////////////////////////////////////////////////////////////////////////////
25

    
26
  static synchronized void remove(DistortedObject obj)
27
    {
28
    mObjects.remove(obj);
29
    }
30
  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

    
33
  static DistortedObject get(long id)
34
    {
35
    return mObjects.get(id);
36
    }
37
  
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39
  
40
  static synchronized void reset()
41
    {
42
    for(long id: mObjects.keySet())
43
      {
44
      get(id).resetTexture();  
45
      }
46
    }
47

    
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

    
50
  static synchronized void release()
51
    {
52
    for(long id: mObjects.keySet())
53
      {
54
      get(id).releasePriv();  
55
      }
56
   
57
    mObjects.clear();
58
    id = 0;
59
    }
60
  
61
///////////////////////////////////////////////////////////////////////////////////////////////////
62
  }
(6-6/30)