001
014
015 package com.liferay.portal.kernel.util;
016
017 import java.util.HashSet;
018 import java.util.Set;
019
020
023 public class PrimitiveIntSet {
024
025 public PrimitiveIntSet() {
026 _elements = new HashSet<Integer>();
027 }
028
029 public PrimitiveIntSet(int capacity) {
030 _elements = new HashSet<Integer>(capacity);
031 }
032
033 public void add(int value) {
034 _elements.add(value);
035 }
036
037 public void addAll(int[] values) {
038 for (int value : values) {
039 _elements.add(value);
040 }
041 }
042
043 public int[] getArray() {
044 int[] values = new int[_elements.size()];
045
046 int counter = 0;
047
048 for (Integer element : _elements) {
049 values[counter] = element;
050
051 counter++;
052 }
053
054 return values;
055 }
056
057 public int size() {
058 return _elements.size();
059 }
060
061 private Set<Integer> _elements;
062
063 }