1
/*******************************************************************************
2
* Copyright (c) 2006, 2009 QNX Software Systems 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
* QNX - Initial API and implementation
10
* Markus Schorn (Wind River Systems)
11
*******************************************************************************/
12
package org.eclipse.cdt.internal.core.pdom.db;
14
import org.eclipse.core.runtime.CoreException;
17
* This is a list item. It contains a next and prev pointer
18
* as well as a pointer to the item.
21
* @author Doug Schaefer
23
public class ListItem {
24
protected final Database db;
25
protected final long record;
27
protected static final int NEXT = 0;
28
protected static final int PREV = 4;
29
protected static final int ITEM = 8;
31
protected static final int RECORD_SIZE = 12;
33
public ListItem(Database db, long record) {
38
public ListItem(Database db) throws CoreException {
40
this.record = db.malloc(RECORD_SIZE);
43
public long getRecord() {
48
public boolean equals(Object obj) {
51
else if (obj instanceof ListItem)
52
return record == ((ListItem)obj).record;
57
public void setItem(long item) throws CoreException {
58
db.putRecPtr(record + ITEM, item);
61
public long getItem() throws CoreException {
62
return db.getRecPtr(record + ITEM);
65
public void setNext(ListItem next) throws CoreException {
66
db.putRecPtr(record + NEXT, next.getRecord());
69
public ListItem getNext() throws CoreException {
70
long next = db.getRecPtr(record + NEXT);
71
return next != 0 ? new ListItem(db, next) : null;
74
public void setPrev(ListItem prev) throws CoreException {
75
db.putRecPtr(record + PREV, prev.getRecord());
78
public ListItem getPrev() throws CoreException {
79
long prev = db.getRecPtr(record + PREV);
80
return prev != 0 ? new ListItem(db, prev) : null;
83
public void delete() throws CoreException {