| PrimitiveLongSet.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 *
12 *
13 */
14
15 package com.liferay.portal.kernel.util;
16
17 import java.util.HashSet;
18 import java.util.Set;
19
20 /**
21 * <a href="PrimitiveLongSet.java.html"><b><i>View Source</i></b></a>
22 *
23 * @author Michael C. Han
24 */
25 public class PrimitiveLongSet {
26
27 public PrimitiveLongSet() {
28 _elements = new HashSet<Long>();
29 }
30
31 public PrimitiveLongSet(int capacity) {
32 _elements = new HashSet<Long>(capacity);
33 }
34
35 public void add(long value) {
36 _elements.add(value);
37 }
38
39 public void addAll(long[] values) {
40 for (long value : values) {
41 _elements.add(value);
42 }
43 }
44
45 public long[] getArray() {
46 long[] values = new long[_elements.size()];
47
48 int counter = 0;
49
50 for (Long element : _elements) {
51 values[counter] = element;
52
53 counter++;
54 }
55
56 return values;
57 }
58
59 public int size() {
60 return _elements.size();
61 }
62
63 private Set<Long> _elements;
64
65 }