KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > utilint > LevelOrderedINMap


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: LevelOrderedINMap.java,v 1.7 2006/10/30 21:14:29 bostic Exp $
7  */

8
9 package com.sleepycat.je.utilint;
10
11 import java.util.HashSet JavaDoc;
12 import java.util.Set JavaDoc;
13 import java.util.TreeMap JavaDoc;
14
15 import com.sleepycat.je.tree.IN;
16
17 /**
18  * A level ordered map holds collection of INs, sorted by level. The map is
19  * keyed by level and each datum is a set of INs belonging to that level.
20  */

21 public class LevelOrderedINMap extends TreeMap JavaDoc {
22     
23     public void putIN(IN in) {
24         Integer JavaDoc level = new Integer JavaDoc(in.getLevel());
25         Set JavaDoc inSet = (Set JavaDoc) get(level);
26         if (inSet == null) {
27             inSet = new HashSet JavaDoc();
28             put(level, inSet);
29         }
30         inSet.add(in);
31     }
32 }
33
Popular Tags