blob: fafd5e5415fee3c6aeca6c1ef9c4b862f95d0ad4 (
plain) (
blame)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package com.windriver.debug.tcf.ui.model;
import java.util.HashMap;
import java.util.Map;
public class TCFChildren {
final TCFNode node;
final Map<String,TCFNode> children = new HashMap<String,TCFNode>();
final Map<String,TCFNode> children_next = new HashMap<String,TCFNode>();
protected boolean valid;
TCFChildren(TCFNode node) {
this.node = node;
}
void dispose() {
TCFNode arr[] = children.values().toArray(new TCFNode[children.size()]);
for (int i = 0; i < arr.length; i++) arr[i].dispose();
assert children.isEmpty();
}
void dispose(String id) {
children.remove(id);
}
void doneValidate() {
valid = true;
TCFNode[] a = children.values().toArray(new TCFNode[children.size()]);
for (TCFNode n : a) {
if (children_next.get(n.id) != n) n.dispose();
}
for (TCFNode n : children_next.values()) {
if (children.get(n.id) == null) {
children.put(n.id, n);
n.model.addNode(n.id, n);
}
assert children.get(n.id) == n;
}
assert children.size() == children_next.size();
}
boolean validate(TCFRunnable done) {
doneValidate();
return true;
}
void invalidate() {
children_next.clear();
TCFNode[] a = children.values().toArray(new TCFNode[children.size()]);
for (int i = 0; i < a.length; i++) a[i].invalidateNode(TCFNode.CF_ALL);
valid = false;
}
int size() {
return children.size();
}
TCFNode[] toArray() {
return children.values().toArray(new TCFNode[children.size()]);
}
}
|