1 6 7 package com.hp.hpl.jena.graph; 8 9 19 public class NodeCache 20 { 21 25 private static int SIZE = 5000; 26 27 30 private Node [] nodes = new Node [SIZE]; 31 32 35 public void clear() 36 { for (int i = 0; i < SIZE; i += 1) nodes[i] = null; } 37 38 public int size() 39 { return 0; } 40 41 private int hits = 0; 42 private int misses = 0; 43 44 47 private int count() 48 { 49 int result = 0; 50 for (int i = 0; i < SIZE; i += 1) if (nodes[i] != null) result += 1; 51 return result; 52 } 53 54 60 public Node get( Object label ) 61 { 62 Node present = nodes[(label.hashCode() & 0x7fffffff) % SIZE]; 63 return present == null || !label.equals( present.label ) ? null : present; 66 } 67 68 72 public void put( Object label, Node cached ) 73 { 74 nodes[(label.hashCode() & 0x7fffffff) % SIZE] = cached; 75 } 76 } 77 78 | Popular Tags |