⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setoperations.java

📁 好东西啊!你看看就知道了
💻 JAVA
字号:
package org.w3c.rdf.util;import org.w3c.rdf.model.*;import java.util.*;/** * An implementation of set operations on models. * Every of these static methods first attempts to use the native implementation provided by the model if any. */public class SetOperations {  public static void copy(Model src, Model dest) throws ModelException {    subtract(dest, dest);    unite(dest, src);  }  public static Model union(Model m1, Model m2) throws ModelException {    Model res = m1.duplicate();    unite(res, m2);    return res;  }  public static void unite(Model m1, Model m2) throws ModelException {    if(m1 instanceof SetModel)      ((SetModel)m1).unite(m2);    else {      synchronized(m2) {	for(Enumeration en = m2.elements(); en.hasMoreElements();)	  m1.add( (Statement)en.nextElement() );      }    }  }  public static Model difference(Model m1, Model m2) throws ModelException {    Model res = m1.duplicate();    subtract(res, m2);    return res;  }  public static void subtract(Model m1, Model m2) throws ModelException {    if(m1 instanceof SetModel)      ((SetModel)m1).subtract(m2);    else {      synchronized(m2) {	for(Enumeration en = m2.elements(); en.hasMoreElements();)	  m1.remove( (Statement)en.nextElement() );      }    }  }  public static Model intersection(Model m1, Model m2) throws ModelException {    Model res = m1.duplicate();    intersect(res, m2);    return res;  }  public static void intersect(Model m1, Model m2) throws ModelException {    if(m1 instanceof SetModel)      ((SetModel)m1).intersect(m2);    else {      synchronized(m2) {	Model tmp = m1.duplicate();	for(Enumeration en = tmp.elements(); en.hasMoreElements();) {	  Statement t = (Statement)en.nextElement();	  if(!m2.contains(t))	    m1.remove(t);	}      }    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -