本文整理汇总了Java中org.eclipse.imp.pdb.facts.IValueFactory类的典型用法代码示例。如果您正苦于以下问题:Java IValueFactory类的具体用法?Java IValueFactory怎么用?Java IValueFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IValueFactory类属于org.eclipse.imp.pdb.facts包,在下文中一共展示了IValueFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isEqual
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static boolean isEqual(IValueFactory vf, ISet set1, IValue other) {
// return equals(vf, set1, other);
if (other == set1)
return true;
if (other == null)
return false;
if (other instanceof ISet) {
ISet set2 = (ISet) other;
if (set1.size() == set2.size()) {
for (IValue v1 : set1) {
// function contains() calls isEqual() but used O(n) time
if (contains(vf, set2, v1) == false)
return false;
}
return true;
}
}
return false;
}
示例2: closure
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static ISet closure(IValueFactory vf, ISet rel1) {
if (rel1.getElementType() == TF.voidType())
return rel1;
if (!isBinary(rel1))
throw new IllegalOperationException("closure", rel1.getType());
Type tupleElementType = rel1.getElementType().getFieldType(0).lub(rel1.getElementType().getFieldType(1));
Type tupleType = TF.tupleType(tupleElementType, tupleElementType);
java.util.Set<IValue> closureDelta = computeClosureDelta(vf, rel1, tupleType);
// NOTE: type is already known, thus, using a SetWriter degrades performance
ISetWriter resultWriter = vf.setWriter(tupleType);
resultWriter.insertAll(rel1);
resultWriter.insertAll(closureDelta);
return resultWriter.done();
}
示例3: delete
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static IList delete(IValueFactory vf, IList list1, int index) {
IListWriter w = vf.listWriter();
int currentIndex = 0;
boolean deleted = false;
for (Iterator<IValue> iterator = list1.iterator(); iterator.hasNext(); currentIndex++) {
IValue e = iterator.next();
if (!deleted && index == currentIndex) {
deleted = true; // skip first occurrence
} else {
w.append(e);
}
}
return w.done();
}
示例4: closure
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static IList closure(IValueFactory vf, IList list1) {
// will throw exception if not binary and reflexive
list1.getType().closure();
IList tmp = list1;
int prevCount = 0;
ShareableValuesHashSet addedTuples = new ShareableValuesHashSet();
while (prevCount != tmp.length()) {
prevCount = tmp.length();
IList tcomp = compose(vf, tmp, tmp);
IListWriter w = vf.listWriter();
for (IValue t1 : tcomp) {
if (!tmp.contains(t1)) {
if (!addedTuples.contains(t1)) {
addedTuples.add(t1);
w.append(t1);
}
}
}
tmp = tmp.concat(w.done());
addedTuples.clear();
}
return tmp;
}
示例5: carrier
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static IList carrier(IValueFactory vf, IList rel1) {
IListWriter w = vf.listWriter();
java.util.HashSet<IValue> cache = new java.util.HashSet<>();
for (IValue v : rel1) {
ITuple t = (ITuple) v;
for (IValue e : t) {
if (!cache.contains(e)) {
cache.add(e);
w.append(e);
}
}
}
return w.done();
}
示例6: range
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static IList range(IValueFactory vf, IList rel1) {
int columnIndex = rel1.getType().getArity() - 1;
IListWriter w = vf.listWriter();
java.util.HashSet<IValue> cache = new java.util.HashSet<>();
for (IValue elem : rel1) {
ITuple tuple = (ITuple) elem;
IValue e = tuple.get(columnIndex);
if (!cache.contains(e)) {
cache.add(e);
w.append(e);
}
}
return w.done();
}
示例7: projectByFieldNames
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static IList projectByFieldNames(IValueFactory vf, IList list1, String... fields) {
int[] indexes = new int[fields.length];
int i = 0;
if (list1.getType().getFieldTypes().hasFieldNames()) {
for (String field : fields) {
indexes[i++] = list1.getType().getFieldTypes()
.getFieldIndex(field);
}
return project(vf, list1, indexes);
}
throw new IllegalOperationException("select with field names",
list1.getType());
}
示例8: compose
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static IMap compose(IValueFactory vf, IMap map1, IMap map2) {
Type newMapType;
if (map1.getType().hasFieldNames() && map2.getType().hasFieldNames()) {
newMapType = TypeFactory.getInstance().mapType(
map1.getType().getKeyType(), map1.getType().getKeyLabel(),
map2.getType().getValueType(),
map2.getType().getValueLabel());
} else {
newMapType = TypeFactory.getInstance().mapType(map1.getKeyType(),
map2.getValueType());
}
IMapWriter w = vf.mapWriter(newMapType);
Iterator<Entry<IValue, IValue>> iter = map1.entryIterator();
while (iter.hasNext()) {
Entry<IValue, IValue> e = iter.next();
IValue value = map2.get(e.getValue());
if (value != null) {
w.put(e.getKey(), value);
}
}
return w.done();
}
示例9: read
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public IValue read(IValueFactory factory, TypeStore store, Type type, Reader stream)
throws FactTypeUseException, IOException {
this.vf = factory;
this.ts = store;
try {
Document doc = domFactory.newDocumentBuilder().parse(new InputSource(stream));
return parse(doc.getDocumentElement(), type);
} catch (SAXException se) {
throw new IOException("Parsing of value failed because XML was invalid: " + se.getMessage());
} catch (ParserConfigurationException pce) {
throw new IOException("Parsing of value failed because XML configuration is wrong: " + pce.getMessage());
} catch (DOMException de) {
throw new IOException("Parsing of value failed because of a XML document failure: " + de.getMessage());
} catch (NumberFormatException nfe) {
throw new FactParseError("Expected a number, got something different", nfe);
}
}
示例10: readValueFromFile
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
/**
* Reads the value from the given file.
*
* @param valueFactory
* The value factory to use.
* @param typeStore
* The typestore to use.
* @param file
* The file to read from.
* @return The resulting value.
* @throws IOException
* Thrown when something goes wrong.
*/
public static IValue readValueFromFile(IValueFactory valueFactory, TypeStore typeStore, File file) throws IOException{
IValue result;
InputStream fis = null;
try{
fis = new BufferedInputStream(new FileInputStream(file));
BinaryReader binaryReader = new BinaryReader(valueFactory, typeStore, fis);
result = binaryReader.deserialize();
}finally{
if(fis != null){
fis.close();
}
}
return result;
}
示例11: BinaryReader
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public BinaryReader(IValueFactory valueFactory, TypeStore typeStore, InputStream inputStream){
super();
this.valueFactory = valueFactory;
this.typeStore = typeStore;
this.in = inputStream;
sharedValues = new ResizingArray<>(DEFAULT_SHARED_VALUES_STORE_SIZE);
currentSharedValueId = 0;
sharedTypes = new ResizingArray<>(DEFAULT_SHARED_TYPES_STORE_SIZE);
currentSharedTypeId = 0;
sharedPaths = new ResizingArray<>(DEFAULT_SHARED_PATHS_STORE_SIZE);
currentSharedPathId = 0;
sharedNames = new ResizingArray<>(DEFAULT_SHARED_NAMES_STORE_SIZE);
currentSharedNamesId = 0;
}
示例12: read
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
@SuppressWarnings("serial")
public IValue read(IValueFactory factory, TypeStore store, Type type, Reader stream) throws FactTypeUseException, IOException {
this.store = store;
this.stream = new NoWhiteSpaceReader(stream);
this.factory = factory;
this.types = TypeFactory.getInstance();
try {
sourceLocationCache = new LinkedHashMap<String, ISourceLocation>(400*4/3, 0.75f, true) {
@Override
protected boolean removeEldestEntry(java.util.Map.Entry<String, ISourceLocation> eldest) {
return size() > 400;
}
};
current = this.stream.read();
IValue result = readValue(type);
if (current != -1 || this.stream.read() != -1) {
unexpected();
}
return result;
}
finally {
sourceLocationCache.clear();
sourceLocationCache = null;
}
}
示例13: testEqualityAfterInsertDelete
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
@Test
public void testEqualityAfterInsertDelete() {
IValueFactory valueFactory = ValueFactory.getInstance();
int size = 50;
ISetWriter writer1 = valueFactory.setWriter();
ISetWriter writer2 = valueFactory.setWriter();
for (int i = size; i > 0; i--) {
writer1.insert(valueFactory.integer(i));
writer2.insert(valueFactory.integer(i));
}
ISet testSet = writer1.done();
ISet testSetDuplicate = writer2.done();
// IValue VALUE_EXISTING = valueFactory.integer(size - 1);
IValue VALUE_NOT_EXISTING = valueFactory.integer(size + 1);
testSetDuplicate = testSet.insert(VALUE_NOT_EXISTING);
testSetDuplicate = testSetDuplicate.delete(VALUE_NOT_EXISTING);
boolean equals = testSet.equals(testSetDuplicate);
assertTrue (equals);
}
示例14: setUp
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
protected void setUp(IValueFactory factory) throws Exception {
super.setUp();
vf = factory;
integers = new IValue[20];
IListWriter w = vf.listWriter(tf.integerType());
for (int i = 0; i < integers.length; i++) {
integers[i] = vf.integer(i);
}
for (int i = integers.length - 1; i >= 0; i--) {
w.insert(vf.integer(i));
}
integerList = w.done();
emptyIntegerList = vf.listWriter(tf.integerType()).done();
}
示例15: contains
import org.eclipse.imp.pdb.facts.IValueFactory; //导入依赖的package包/类
public static boolean contains(IValueFactory vf, ISet set1, IValue e) {
for (IValue v : set1) {
if (v.isEqual(e)) {
return true;
}
}
return false;
}