本文整理汇总了Java中net.mindview.util.RandomGenerator类的典型用法代码示例。如果您正苦于以下问题:Java RandomGenerator类的具体用法?Java RandomGenerator怎么用?Java RandomGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RandomGenerator类属于net.mindview.util包,在下文中一共展示了RandomGenerator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
Generator<String> gen = new RandomGenerator.String(20);
Set<StringKey41> set = new HashSet<StringKey41>();
final int count = 1000;
for(int i = 0; i < count; i++) {
set.add(new StringKey41(gen.next(), gen.next()));
}
print(set);
Map<StringKey41, String> map = new HashMap<StringKey41, String>();
for(int i = 0; i < count; i++) {
map.put(new StringKey41(gen.next(), gen.next()), gen.next());
}
print(map);
}
示例2: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
RandomGenerator.String rg = new RandomGenerator.String();
Set<TwoStringsComparable> set = new HashSet<>();
// for (int i = 0; i < 5; i++) {
// set.add(new TwoStringsComparable(rg.next(), rg.next()));
// }
set.add(new TwoStringsComparable("a", "b"));
set.add(new TwoStringsComparable("a", "b"));
System.out.println(set);
Map<TwoStringsComparable, String> map = new HashMap<>();
map.put(new TwoStringsComparable("x", "z"), "first");
System.out.println(map);
map.put(new TwoStringsComparable("x", "z"), "second");
System.out.println(map);
}
示例3: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
RandomGenerator.Integer rgi = new RandomGenerator.Integer(10000);
print("Testing map m of <String,String>: the basics:");
SimpleHashMap39<String,String> m = new SimpleHashMap39<String,String>();
m.putAll(Countries.capitals(10));
print("m: " + m);
print("m.get(\"CHAD\") " + m.get("CHAD"));
print("m.size() = " + m.size());
print("m.capacity() = " + m.capacity());
print("Testing rehash() for a map m2 of <Integer,Integer>:");
SimpleHashMap39<Integer,Integer> m2 = new SimpleHashMap39<Integer,Integer>();
print("m2: " + m2);
print("m2.size() = " + m2.size());
print("m2.capacity() = " + m2.capacity());
m2.putAll(MapData.map(rgi, rgi, 996));
print("after m2.putAll(MapData.map(rgi, rgi, 996): ");
print("m2.size() = " + m2.size());
print("m2.capacity() = " + m2.capacity());
m2.putAll(MapData.map(rgi, rgi, 2000));
print("after m2.putAll(MapData.map(rgi, rgi, 2000): ");
print("m2.size() = " + m2.size());
print("m2.capacity() = " + m2.capacity());
m2.putAll(MapData.map(rgi, rgi, 1500));
print("after m2.putAll(MapData.map(rgi, rgi, 1500): ");
print("m2.size() = " + m2.size());
print("m2.capacity() = " + m2.capacity());
}
示例4: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
Set<String> randomStrings = new TreeSet<String>();
Generator<String> gen = new RandomGenerator.String(10);
for(int i = 0; i < 100; i++) {
randomStrings.add(gen.next());
}
for(String item: randomStrings)
System.out.println(item);
}
示例5: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
SortedSet<Integer> mySet = new MySortedSet<Integer>();
SortedSet<Integer> rightSet = new TreeSet<Integer>();
List<Integer> insertionOrder = new LinkedList<Integer>();
Generator<Integer> gen = new RandomGenerator.Integer(25);
for(int i = 0; i < 25; i++) {
int value = gen.next();
mySet.add(value);
rightSet.add(value);
insertionOrder.add(value);
}
System.out.println(insertionOrder);
System.out.println(mySet);
System.out.println(rightSet);
System.out.println(mySet.equals(rightSet));
System.out.println(mySet == rightSet);
System.out.println(mySet.first() == rightSet.first());
System.out.println(mySet.last() == rightSet.last());
System.out.println(mySet.subSet(1, 10));
System.out.println(rightSet.subSet(1, 10));
System.out.println(mySet.headSet(10));
System.out.println(rightSet.headSet(10));
System.out.println(mySet.tailSet(0));
System.out.println(rightSet.tailSet(0));
}
示例6: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
RandomGenerator.String rg = new RandomGenerator.String();
List<TwoStringsComparable> list = new ArrayList<>();
for (int i = 0; i < 5; i++) {
list.add(new TwoStringsComparable(rg.next(), rg.next()));
}
System.out.println("Initial list: " + list);
Collections.sort(list);
System.out.println("Sorted by first field: " + list);
Collections.sort(list, new TwoStringsSecondFieldComparator());
System.out.println("Sorted by second field: " + list);
}
示例7: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
Generator<String> gen = new RandomGenerator.String(20);
int count = 1000;
StringFirst40[] firstArray = new StringFirst40[count];
List<StringFirst40> firstList = new ArrayList<StringFirst40>(count);
for(int i = 0; i < count; i++) {
firstArray[i] = new StringFirst40(gen.next(), gen.next());
}
firstList.addAll(Arrays.asList(firstArray));
printArray(firstArray);
print(firstList);
Arrays.sort(firstArray);
Collections.sort(firstList);
printArray(firstArray);
print(firstList);
Arrays.sort(firstArray, new Comp2());
Collections.sort(firstList, new Comp2());
printArray(firstArray);
print(firstList);
Random rand = new Random();
int index = -1;
do{
index = rand.nextInt(count);
} while( index <= 0);
StringFirst40 randItem = firstArray[index];
int found1 = Arrays.binarySearch(firstArray, randItem, new Comp2());
int found2 = Collections.binarySearch(firstList, randItem, new Comp2());
print(firstArray[found1].equals(firstArray[index]));
print(firstList.get(found2).equals(firstList.get(index)));
}
示例8: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
Generator<String> gen = new RandomGenerator.String(20);
int count = 1000;
StringFirst40[] firstArray = new StringFirst40[count];
List<StringFirst40> firstList = new ArrayList<StringFirst40>(count);
for(int i = 0; i < count; i++) {
firstArray[i] = new StringFirst40(gen.next(), gen.next());
}
firstList.addAll(Arrays.asList(firstArray));
printArray(firstArray);
print(firstList);
Arrays.sort(firstArray);
Collections.sort(firstList);
printArray(firstArray);
print(firstList);
Arrays.sort(firstArray, StringFirst40.secondComparator);
Collections.sort(firstList, StringFirst40.secondComparator);
printArray(firstArray);
print(firstList);
Random rand = new Random();
int index = -1;
do{
index = rand.nextInt(count);
} while( index <= 0);
StringFirst40 randItem = firstArray[index];
int found1 = Arrays.binarySearch(firstArray, randItem, StringFirst40.secondComparator);
int found2 = Collections.binarySearch(firstList, randItem, StringFirst40.secondComparator);
print(firstArray[found1].equals(firstArray[index]));
print(firstList.get(found2).equals(firstList.get(index)));
}
示例9: main
import net.mindview.util.RandomGenerator; //导入依赖的package包/类
public static void main(String[] args) {
Set<String> ts = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
ts.addAll(CollectionData.list(new RandomGenerator.String(), 20));
System.out.println(ts);
}