001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.jikesrvm.util;
014
015/**
016 * Stripped down implementation of HashSet for use
017 * by core parts of the JikesRVM runtime. Consider the use of
018 * {@link ImmutableEntryHashSetRVM} when the use of the HashSet
019 * methods is limited.
020 */
021public final class HashSetRVM<T> extends AbstractHashSetRVM<T> {
022  static final class Bucket<T> extends AbstractBucket<T> {
023    private final T key;
024    private AbstractBucket<T> next;
025
026    Bucket(T key, AbstractBucket<T> next) {
027      this.key = key;
028      this.next = next;
029    }
030
031    @Override
032    AbstractBucket<T> setNext(AbstractBucket<T> next) {
033      this.next = next;
034      return this;
035    }
036
037    @Override
038    AbstractBucket<T> getNext() {
039      return next;
040    }
041
042    @Override
043    T getKey() {
044      return key;
045    }
046  }
047
048  @Override
049  AbstractBucket<T> createNewBucket(T key, AbstractBucket<T> next) {
050    return new Bucket<T>(key, next);
051  }
052
053  public HashSetRVM() {
054    super(DEFAULT_SIZE);
055  }
056
057  public HashSetRVM(int size) {
058    super(size);
059  }
060}