mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
Cosmetics.
This commit is contained in:
parent
af1c5c31d1
commit
0ea6b2101a
3 changed files with 50 additions and 57 deletions
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Niefer (IBM Corporation) - Initial API and implementation
|
||||
* Andrew Niefer (IBM Corporation) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.util;
|
||||
|
||||
|
@ -15,47 +15,47 @@ import java.util.List;
|
|||
|
||||
public class CharArraySet extends CharTable {
|
||||
|
||||
public static final CharArraySet EMPTY_SET = new CharArraySet( 0 ){
|
||||
public static final CharArraySet EMPTY_SET = new CharArraySet(0) {
|
||||
@Override
|
||||
public Object clone() { return this; }
|
||||
public Object clone() { return this; }
|
||||
@Override
|
||||
public List<char[]> toList() { return Collections.emptyList(); }
|
||||
public List<char[]> toList() { return Collections.emptyList(); }
|
||||
@Override
|
||||
public void put( char[] key ) { throw new UnsupportedOperationException(); }
|
||||
public void put(char[] key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public void addAll( List<char[]> list ) { throw new UnsupportedOperationException(); }
|
||||
public void addAll(List<char[]> list) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public void addAll( CharArraySet set ) { throw new UnsupportedOperationException(); }
|
||||
public void addAll(CharArraySet set) { throw new UnsupportedOperationException(); }
|
||||
};
|
||||
|
||||
public CharArraySet(int initialSize) {
|
||||
super(initialSize);
|
||||
}
|
||||
|
||||
public void put(char[] key ){
|
||||
public void put(char[] key) {
|
||||
addIndex(key);
|
||||
}
|
||||
|
||||
public void addAll( List<char[]> list ){
|
||||
if( list == null )
|
||||
public void addAll(List<char[]> list) {
|
||||
if (list == null)
|
||||
return;
|
||||
|
||||
int size = list.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
addIndex( list.get( i ) );
|
||||
for (int i = 0; i < size; i++) {
|
||||
addIndex(list.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void addAll( CharArraySet set ){
|
||||
if( set == null )
|
||||
public void addAll(CharArraySet set) {
|
||||
if (set == null)
|
||||
return;
|
||||
int size = set.size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
addIndex( set.keyAt( i ) );
|
||||
for (int i = 0; i < size; i++) {
|
||||
addIndex(set.keyAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
final public boolean remove( char[] key ) {
|
||||
final public boolean remove(char[] key) {
|
||||
int i = lookup(key);
|
||||
if (i < 0)
|
||||
return false;
|
||||
|
@ -65,11 +65,11 @@ public class CharArraySet extends CharTable {
|
|||
}
|
||||
|
||||
@Override
|
||||
final public void clear(){
|
||||
for( int i = 0; i < keyTable.length; i++ ){
|
||||
final public void clear() {
|
||||
for (int i = 0; i < keyTable.length; i++) {
|
||||
keyTable[i] = null;
|
||||
hashTable[ 2*i ] = 0;
|
||||
hashTable[ 2*i + 1 ] = 0;
|
||||
hashTable[2 * i] = 0;
|
||||
hashTable[2 * i + 1] = 0;
|
||||
nextTable[i] = 0;
|
||||
}
|
||||
currEntry = -1;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.parser.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -18,7 +17,6 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* @author ddaoust
|
||||
*
|
||||
*/
|
||||
public class CharTable extends HashTable {
|
||||
protected char[][] keyTable;
|
||||
|
@ -39,12 +37,12 @@ public class CharTable extends HashTable {
|
|||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
for( int i = 0; i < capacity(); i++ )
|
||||
for (int i = 0; i < capacity(); i++)
|
||||
keyTable[i] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone(){
|
||||
public Object clone() {
|
||||
CharTable newTable = (CharTable) super.clone();
|
||||
|
||||
int size = capacity();
|
||||
|
@ -59,53 +57,49 @@ public class CharTable extends HashTable {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected final int hash( int pos ){
|
||||
protected final int hash(int pos) {
|
||||
return hash(keyTable[pos], 0, keyTable[pos].length);
|
||||
}
|
||||
|
||||
protected final int hash( char[] obj ){
|
||||
return hash( obj, 0, obj.length );
|
||||
protected final int hash(char[] obj) {
|
||||
return hash(obj, 0, obj.length);
|
||||
}
|
||||
|
||||
protected final int addIndex(char[] buffer ) {
|
||||
protected final int addIndex(char[] buffer) {
|
||||
return addIndex(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
public final int addIndex(char[] buffer, int start, int len) {
|
||||
if (hashTable != null)
|
||||
{
|
||||
if (hashTable != null) {
|
||||
int hash = hash(buffer, start, len);
|
||||
int pos = lookup(buffer, start, len, hash);
|
||||
if (pos != -1)
|
||||
return pos;
|
||||
|
||||
// key is not here, add it.
|
||||
if( (currEntry + 1) >= capacity()) {
|
||||
if ((currEntry + 1) >= capacity()) {
|
||||
resize();
|
||||
hash = hash(buffer, start, len);
|
||||
}
|
||||
currEntry++;
|
||||
keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len);
|
||||
linkIntoHashTable(currEntry, hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
int pos = lookup(buffer, start, len);
|
||||
if (pos != -1)
|
||||
return pos;
|
||||
// key is not here, add it.
|
||||
if( (currEntry + 1) >= capacity()) {
|
||||
if ((currEntry + 1) >= capacity()) {
|
||||
resize();
|
||||
if( capacity() > minHashSize ){
|
||||
if (capacity() > minHashSize) {
|
||||
//if we grew from list to hash, then recurse and add as a hashtable
|
||||
return addIndex( buffer, start, len );
|
||||
return addIndex(buffer, start, len);
|
||||
}
|
||||
}
|
||||
currEntry++;
|
||||
keyTable[currEntry] = CharArrayUtils.extract(buffer, start, len);
|
||||
}
|
||||
return currEntry;
|
||||
|
||||
}
|
||||
|
||||
protected void removeEntry(int i) {
|
||||
|
@ -120,17 +114,17 @@ public class CharTable extends HashTable {
|
|||
removeEntry(i, hash);
|
||||
}
|
||||
|
||||
public List<char[]> toList(){
|
||||
List<char[]> list = new ArrayList<char[]>( size() );
|
||||
public List<char[]> toList() {
|
||||
List<char[]> list = new ArrayList<char[]>(size());
|
||||
int size = size();
|
||||
for( int i = 0; i < size; i++ ){
|
||||
list.add( keyAt( i ) );
|
||||
for (int i = 0; i < size; i++) {
|
||||
list.add(keyAt(i));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public final char[] keyAt( int i ){
|
||||
if( i < 0 || i > currEntry )
|
||||
public final char[] keyAt(int i) {
|
||||
if (i < 0 || i > currEntry)
|
||||
return null;
|
||||
|
||||
return keyTable[ i ];
|
||||
|
@ -140,25 +134,25 @@ public class CharTable extends HashTable {
|
|||
return lookup(key, start, len) != -1;
|
||||
}
|
||||
|
||||
public final boolean containsKey(char[] key){
|
||||
public final boolean containsKey(char[] key) {
|
||||
return lookup(key) != -1;
|
||||
}
|
||||
|
||||
public final char[] findKey( char[] buffer, int start, int len ){
|
||||
int idx = lookup( buffer, start, len );
|
||||
if( idx == -1 )
|
||||
public final char[] findKey(char[] buffer, int start, int len) {
|
||||
int idx = lookup(buffer, start, len);
|
||||
if (idx == -1)
|
||||
return null;
|
||||
|
||||
return keyTable[ idx ];
|
||||
}
|
||||
|
||||
public int lookup(char[] buffer ){
|
||||
public int lookup(char[] buffer) {
|
||||
return lookup(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
protected final int lookup(char[] buffer, int start, int len) {
|
||||
if (hashTable != null)
|
||||
return lookup(buffer, start, len, hash(buffer, start, len) );
|
||||
return lookup(buffer, start, len, hash(buffer, start, len));
|
||||
for (int i = 0; i <= currEntry; i++) {
|
||||
if (CharArrayUtils.equals(buffer, start, len, keyTable[i]))
|
||||
return i;
|
||||
|
@ -182,9 +176,9 @@ public class CharTable extends HashTable {
|
|||
return -1;
|
||||
}
|
||||
|
||||
public Object [] keyArray(){
|
||||
Object [] keys = new Object[ size() ];
|
||||
System.arraycopy( keyTable, 0, keys, 0, keys.length );
|
||||
public Object[] keyArray() {
|
||||
Object[] keys = new Object[ size() ];
|
||||
System.arraycopy(keyTable, 0, keys, 0, keys.length);
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
|
|||
if (project != null) {
|
||||
fIndexerSetupParticipant.notifyIndexerSetup(project);
|
||||
}
|
||||
}
|
||||
else if (old != null && changedDefaultSettingConfiguration(old, act)) {
|
||||
} else if (old != null && changedDefaultSettingConfiguration(old, act)) {
|
||||
ICProject project= getProject(event);
|
||||
if (project != null) {
|
||||
fIndexManager.reindex(project);
|
||||
|
@ -86,7 +85,7 @@ public class CProjectDescriptionListener implements ICProjectDescriptionListener
|
|||
// Check for a project that has been created by the new project wizard just
|
||||
// just for the purpose of editing preferences (Advanced button)
|
||||
ICProjectDescription desc= CProjectDescriptionManager.getInstance().getProjectDescription(project.getProject(), false, false);
|
||||
return desc==null || !desc.isCdtProjectCreating();
|
||||
return desc == null || !desc.isCdtProjectCreating();
|
||||
}
|
||||
|
||||
private boolean completedProjectCreation(ICProjectDescription old, ICProjectDescription act) {
|
||||
|
|
Loading…
Add table
Reference in a new issue