1
/*******************************************************************************
2
* Copyright (c) 2007 Intel Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Intel Corporation - Initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.managedbuilder.internal.tcmodification;
13
import java.util.LinkedHashSet;
16
public class PerTypeSetStorage implements Cloneable {
17
private ObjectTypeBasedStorage fStorage = new ObjectTypeBasedStorage();
19
public Set getSet(int type, boolean create){
20
Set set = (Set)fStorage.get(type);
21
if(set == null && create){
22
set = createSet(null);
23
fStorage.set(type, set);
28
protected Set createSet(Set set){
30
return new LinkedHashSet();
31
return (Set)((LinkedHashSet)set).clone();
34
public Object clone(){
36
PerTypeSetStorage clone = (PerTypeSetStorage)super.clone();
37
clone.fStorage = (ObjectTypeBasedStorage)fStorage.clone();
38
int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes();
39
for(int i = 0; i < types.length; i++){
40
Object o = clone.fStorage.get(types[i]);
42
clone.fStorage.set(types[i], createSet((Set)o));
46
} catch (CloneNotSupportedException e) {
52
public boolean isEmpty(boolean emptySetAsNull){
53
if(fStorage.isEmpty())
56
int types[] = ObjectTypeBasedStorage.getSupportedObjectTypes();
57
for(int i = 0; i < types.length; i++){
58
Object o = fStorage.get(types[i]);
59
if(o != null && !((Set)o).isEmpty())