Java Code Examples for java.util.ArrayList.clone()

The following are Jave code examples for showing how to use clone() of the java.util.ArrayList class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: joai-project   File: RepositoryManager.java   View Source Code Vote up 6 votes
/**
 *  Gets the SetInfos (directories of files) that are currently configured in the repository.
 *
 * @return    The setInfos.
 * @see       SetInfo
 */
public ArrayList getSetInfos() {
	synchronized (setInfosLock) {
		ArrayList setInfos = arrayListGet(Keys.SET_INFOS, false);
		if (setInfos == null) {
			try {
				adminData.delete(Keys.SET_INFOS);
			} catch (Throwable e) {}
			return null;
		}
		ArrayList retVals = (ArrayList) setInfos.clone();
		String sets = "";
		for (int i = 0; i < retVals.size(); i++)
			sets += ((SetInfo) retVals.get(i)).getSetSpec() + " ";

		//prtln("getSetInfos(): {" + sets.trim() + "}");
		return retVals;
	}
}
 
Example 2
Project: starcor.xul   File: XulBindingSelector.java   View Source Code Vote up 6 votes
@Override
boolean apply(IXulDataSelectContext dataCtx, ArrayList<XulDataNode> ctx, XulDataNode node) {
	val = XulUtils.STR_EMPTY;
	ArrayList<XulDataNode> cloneCtx = (ArrayList<XulDataNode>) ctx.clone();
	if (!_selector.apply(dataCtx, cloneCtx)) {
		return false;
	}

	if (cloneCtx.isEmpty()) {
		return true;
	}

	XulDataNode xulDataNode = cloneCtx.get(0);
	node.setOwnerBinding(xulDataNode.getOwnerBinding());
	this.val = xulDataNode.getValue();
	return true;
}
 
Example 3
Project: PearPlanner   File: Person.java   View Source Code Vote up 5 votes
/**
 * @param cSalutation  String for salutation
 * @param cGivenNames  Array list of strings for given names
 * @param cFamName     String for family name
 * @param cFamNameLast true if family name is at the end
 */
public Person(String cSalutation, ArrayList<String> cGivenNames, String cFamName, Boolean cFamNameLast)
{
    super(true);
    setFamilyName(cFamName);
    givenNames = (ArrayList<String>) cGivenNames.clone();
    setSalutation(cSalutation);
    familyNameLast = cFamNameLast;
    email = "";
}
 
Example 4
Project: sstore-soft   File: NestLoopIndexPlanNode.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
@Override
protected ArrayList<Integer> createOutputColumns(Database db, ArrayList<Integer> input) {
    IndexScanPlanNode inlineScan = (IndexScanPlanNode) m_inlineNodes.get(PlanNodeType.INDEXSCAN);
    assert(inlineScan != null);

    inlineScan.updateOutputColumns(db);
    input.addAll(inlineScan.m_outputColumns);

    return (ArrayList<Integer>) input.clone();
}
 
Example 5
Project: smile_1.5.0_java7   File: MultivariateGaussianMixture.java   View Source Code Vote up 5 votes
/**
 * Constructor. The Gaussian mixture model will be learned from the given data
 * with the EM algorithm. The number of components will be selected by BIC.
 * @param data the training data.
 * @param diagonal true if the components have diagonal covariance matrix.
 */
@SuppressWarnings("unchecked")
public MultivariateGaussianMixture(double[][] data, boolean diagonal) {
    if (data.length < 20)
        throw new IllegalArgumentException("Too few samples.");

    ArrayList<Component> mixture = new ArrayList<>();
    Component c = new Component();
    c.priori = 1.0;
    c.distribution = new MultivariateGaussianDistribution(data, diagonal);
    mixture.add(c);

    int freedom = 0;
    for (int i = 0; i < mixture.size(); i++)
        freedom += mixture.get(i).distribution.npara();

    double bic = 0.0;
    for (double[] x : data) {
        double p = c.distribution.p(x);
        if (p > 0) bic += Math.log(p);
    }
    bic -= 0.5 * freedom * Math.log(data.length);

    double b = Double.NEGATIVE_INFINITY;
    while (bic > b) {
        b = bic;
        components = (ArrayList<Component>) mixture.clone();

        split(mixture);
        bic = EM(mixture, data);

        freedom = 0;
        for (int i = 0; i < mixture.size(); i++)
            freedom += mixture.get(i).distribution.npara();

        bic -= 0.5 * freedom * Math.log(data.length);
    }
}
 
Example 6
Project: smile_1.5.0_java7   File: GaussianMixture.java   View Source Code Vote up 5 votes
/**
 * Constructor. The Gaussian mixture model will be learned from the given data
 * with the EM algorithm. The number of components will be selected by BIC.
 * @param data the training data.
 */
@SuppressWarnings("unchecked")
public GaussianMixture(double[] data) {
    if (data.length < 20)
        throw new IllegalArgumentException("Too few samples.");
    
    ArrayList<Component> mixture = new ArrayList<>();
    Component c = new Component();
    c.priori = 1.0;
    c.distribution = new GaussianDistribution(data);
    mixture.add(c);

    int freedom = 0;
    for (int i = 0; i < mixture.size(); i++)
        freedom += mixture.get(i).distribution.npara();

    double bic = 0.0;
    for (double x : data) {
        double p = c.distribution.p(x);
        if (p > 0) bic += Math.log(p);
    }
    bic -= 0.5 * freedom * Math.log(data.length);

    double b = Double.NEGATIVE_INFINITY;
    while (bic > b) {
        b = bic;
        components = (ArrayList<Component>) mixture.clone();

        split(mixture);
        bic = EM(mixture, data);

        freedom = 0;
        for (int i = 0; i < mixture.size(); i++)
            freedom += mixture.get(i).distribution.npara();

        bic -= 0.5 * freedom * Math.log(data.length);
    }
}
 
Example 7
Project: FacetExtract   File: FindRelationship.java   View Source Code Vote up 5 votes
/**
     * 用于找到一个节点在领域树中距离叶子节点还有几层
     * @param upLocation 上下位关系中,上位关系那一列
	 * @param dnLocation 上下位关系中,下位关系那一列
	 * @param node 目标节点
	 * @return 层数。
	 */
	@SuppressWarnings("unchecked")
	public static int findDistToLeaf(ArrayList<String> upLocation, ArrayList<String> dnLocation, String node){
		int distToLeaf = 0;
		if(IsLeaf(upLocation, node))
			return distToLeaf;
		ArrayList<String> childNodePre = new ArrayList<>();
		HashSet<String> findedNode = new HashSet<>();
		findedNode.add(node);
		childNodePre.add(node);
		while(true)
		{
			ArrayList<String> childNode = new ArrayList<>();
			for(String string : childNodePre)
			{
				if(IsLeaf(upLocation, string))
					return distToLeaf;
				for(int i = 0; i < upLocation.size(); i++)
				{
					if(upLocation.get(i).equals(string))
					{
						if(!findedNode.contains(dnLocation.get(i)))
							childNode.add(dnLocation.get(i));
					}
				}
			}
			childNodePre = (ArrayList<String>) childNode.clone();
			childNode = new ArrayList<>();
			distToLeaf++;
		}
//		return distToLeaf;
	}
 
Example 8
Project: s-store   File: NestLoopIndexPlanNode.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
@Override
protected ArrayList<Integer> createOutputColumns(Database db, ArrayList<Integer> input) {
    IndexScanPlanNode inlineScan = (IndexScanPlanNode) m_inlineNodes.get(PlanNodeType.INDEXSCAN);
    assert(inlineScan != null);

    inlineScan.updateOutputColumns(db);
    input.addAll(inlineScan.m_outputColumns);

    return (ArrayList<Integer>) input.clone();
}
 
Example 9
Project: javaide   File: CodeSuggestAdapter.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
public CodeSuggestAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull ArrayList<Description> objects) {
    super(context, resource, objects);
    this.inflater = LayoutInflater.from(context);
    this.context = context;
    this.clone = (ArrayList<Description>) objects.clone();
    this.suggestion = new ArrayList<>();
    this.resourceID = resource;

    AppSetting appSetting = new AppSetting(context);
    editorTextSize = appSetting.getEditorTextSize();
}
 
Example 10
Project: ModPE-IDE-Source   File: BasicCompletionAdapter.java   View Source Code Vote up 5 votes
@SuppressWarnings({"unchecked", "deprecation"})
public BasicCompletionAdapter(@NonNull Context context,
                              @LayoutRes int resource, @NonNull ArrayList<CompletionItem> objects) {
    super(context, resource, objects);
    this.inflater = LayoutInflater.from(context);
    this.clone = (ArrayList<CompletionItem>) objects.clone();
    this.suggestion = new ArrayList<>();
    this.resourceID = resource;
    colorKeyWord = context.getResources().getColor(android.R.color.primary_text_dark);
    colorNormal = context.getResources().getColor(android.R.color.primary_text_dark);
}
 
Example 11
Project: GitHub   File: ContactsPage.java   View Source Code Vote up 4 votes
private void initData(){
	handler = new EventHandler() {
		@SuppressWarnings("unchecked")
		public void afterEvent(final int event, final int result, final Object data) {
			if (result == SMSSDK.RESULT_COMPLETE) {
				if (event == SMSSDK.EVENT_GET_CONTACTS) {
					// 请求获取本地联系人列表
					ArrayList<HashMap<String,Object>> rawList = (ArrayList<HashMap<String,Object>>) data;
					if (rawList == null) {
						contactsInMobile = new ArrayList<HashMap<String,Object>>();
					} else {
						contactsInMobile = (ArrayList<HashMap<String,Object>>) rawList.clone();
					}
					refreshContactList();
				} else if (event == SMSSDK.EVENT_GET_FRIENDS_IN_APP) {
					// 请求获取服务器上,应用内的朋友
					friendsInApp = (ArrayList<HashMap<String,Object>>) data;
					SMSSDK.getContacts(false);
				}
			} else {
				runOnUIThread(new Runnable() {
					public void run() {
						if (pd != null && pd.isShowing()) {
							pd.dismiss();
						}
						// 网络错误
						int resId = ResHelper.getStringRes(activity, "smssdk_network_error");
						if (resId > 0) {
							Toast.makeText(activity, resId, Toast.LENGTH_SHORT).show();
						}
					}
				});
			}
		}
	};
	// 注册事件监听器
	SMSSDK.registerEventHandler(handler);

	if(friendsInApp != null && friendsInApp.size() > 0) {
		// 获取本地联系人
		SMSSDK.getContacts(false);
	} else {
		// 获取应用内的好友列表
		SMSSDK.getFriendsInApp();
	}
}
 
Example 12
Project: annoflex   File: MultiMapController.java   View Source Code Vote up 4 votes
/**
 * 
 */
@SuppressWarnings("unchecked")
public ArrayList<V> cloneCollection(ArrayList<V> collection) {
    return (ArrayList<V>)collection.clone();
}
 
Example 13
Project: FlickLauncher   File: CellLayout.java   View Source Code Vote up 4 votes
@SuppressWarnings("unchecked")
public ViewCluster(ArrayList<View> views, ItemConfiguration config) {
    this.views = (ArrayList<View>) views.clone();
    this.config = config;
    resetEdges();
}
 
Example 14
Project: SimpleUILauncher   File: CellLayout.java   View Source Code Vote up 4 votes
@SuppressWarnings("unchecked")
public ViewCluster(ArrayList<View> views, ItemConfiguration config) {
    this.views = (ArrayList<View>) views.clone();
    this.config = config;
    resetEdges();
}
 
Example 15
Project: Drones-Simulator   File: PublisherRunner.java   View Source Code Vote up 4 votes
/**
 * @param connectionFactory The connection settings to use for tests.
 * @param topic The topic to publish test messages to.
 * @param testMessages The messages to test.
 */
public PublisherRunner(ConnectionFactory connectionFactory, Topic topic, ArrayList<Message> testMessages) {
    this.publisher = new RabbitPublisher(connectionFactory, new JavaSerializer());
    this.topic = topic;
    this.testMessages = (ArrayList<Message>) testMessages.clone();
}
 
Example 16
Project: FacetExtract   File: FindRelationship.java   View Source Code Vote up 4 votes
/**
 * 用于找到一个特定节点node所有的祖先节点
 * @param upLocation 上下位关系中,上位关系那一列 
 * @param dnLocation 上下位关系中,下位关系那一列
 * @param node 目标节点
 * @return 所有祖先节点。
 */
@SuppressWarnings("unchecked")
public static ArrayList<String> findParent(ArrayList<String> upLocation, ArrayList<String> dnLocation, String node){
	ArrayList<String> newNode = new ArrayList<>();//下一次要遍历的节点
	HashSet<String> findedNode = new HashSet<>();
	findedNode.add(node);
	ArrayList<String> parent = new ArrayList<>();
	ArrayList<String> directParent = new ArrayList<>();//亲父节点
	for(int i = 0; i < upLocation.size(); i++)
	{
		if(dnLocation.get(i).equals(node))
		{
			if(findedNode.contains(upLocation.get(i)))
				continue;
			findedNode.add(upLocation.get(i));
			parent.add(upLocation.get(i));
			newNode.add(upLocation.get(i));
			directParent.add(upLocation.get(i));
		}
	}
	while(newNode.size() != 0)
	{
		ArrayList<String> newnewNode = new ArrayList<>();
		for(int j = 0; j < newNode.size(); j++)
		{
			for(int i = 0; i < upLocation.size(); i++)
			{
				if(dnLocation.get(i).equals(newNode.get(j)))
				{
					if(findedNode.contains(upLocation.get(i)))
						continue;
					findedNode.add(upLocation.get(i));
					parent.add(upLocation.get(i));
					newnewNode.add(upLocation.get(i));
				}
			}
		}
		newNode = (ArrayList<String>) newnewNode.clone();
	}
	return parent;
}
 
Example 17
Project: boohee_v5.6   File: ValueAnimator$AnimationHandler.java   View Source Code Vote up 4 votes
public void handleMessage(Message msg) {
    int i;
    ValueAnimator anim;
    boolean callAgain = true;
    ArrayList<ValueAnimator> animations = (ArrayList) ValueAnimator.access$000().get();
    ArrayList<ValueAnimator> delayedAnims = (ArrayList) ValueAnimator.access$100().get();
    switch (msg.what) {
        case 0:
            ArrayList<ValueAnimator> pendingAnimations = (ArrayList) ValueAnimator.access$200
                    ().get();
            if (animations.size() > 0 || delayedAnims.size() > 0) {
                callAgain = false;
            }
            while (pendingAnimations.size() > 0) {
                ArrayList<ValueAnimator> pendingCopy = (ArrayList) pendingAnimations.clone();
                pendingAnimations.clear();
                int count = pendingCopy.size();
                for (i = 0; i < count; i++) {
                    anim = (ValueAnimator) pendingCopy.get(i);
                    if (ValueAnimator.access$300(anim) == 0) {
                        ValueAnimator.access$400(anim);
                    } else {
                        delayedAnims.add(anim);
                    }
                }
            }
            break;
        case 1:
            break;
        default:
            return;
    }
    long currentTime = AnimationUtils.currentAnimationTimeMillis();
    ArrayList<ValueAnimator> readyAnims = (ArrayList) ValueAnimator.access$500().get();
    ArrayList<ValueAnimator> endingAnims = (ArrayList) ValueAnimator.access$600().get();
    int numDelayedAnims = delayedAnims.size();
    for (i = 0; i < numDelayedAnims; i++) {
        anim = (ValueAnimator) delayedAnims.get(i);
        if (ValueAnimator.access$700(anim, currentTime)) {
            readyAnims.add(anim);
        }
    }
    int numReadyAnims = readyAnims.size();
    if (numReadyAnims > 0) {
        for (i = 0; i < numReadyAnims; i++) {
            anim = (ValueAnimator) readyAnims.get(i);
            ValueAnimator.access$400(anim);
            ValueAnimator.access$802(anim, true);
            delayedAnims.remove(anim);
        }
        readyAnims.clear();
    }
    int numAnims = animations.size();
    i = 0;
    while (i < numAnims) {
        anim = (ValueAnimator) animations.get(i);
        if (anim.animationFrame(currentTime)) {
            endingAnims.add(anim);
        }
        if (animations.size() == numAnims) {
            i++;
        } else {
            numAnims--;
            endingAnims.remove(anim);
        }
    }
    if (endingAnims.size() > 0) {
        for (i = 0; i < endingAnims.size(); i++) {
            ValueAnimator.access$900((ValueAnimator) endingAnims.get(i));
        }
        endingAnims.clear();
    }
    if (!callAgain) {
        return;
    }
    if (!animations.isEmpty() || !delayedAnims.isEmpty()) {
        sendEmptyMessageDelayed(1, Math.max(0, ValueAnimator.access$1000() - (AnimationUtils
                .currentAnimationTimeMillis() - currentTime)));
    }
}
 
Example 18
Project: kourami   File: Path.java   View Source Code Vote up 4 votes
public void setMergedTpOpIndicies(ArrayList<int[]> moi){
this.mergedTpOpIndicies = (ArrayList<int[]>)moi.clone();
   }
 
Example 19
Project: FacetExtract   File: FindRelationship.java   View Source Code Vote up 4 votes
/**
 * 用于找到一个节点在领域树中处于第几层
 * @param upLocation 上下位关系中,上位关系那一列 
 * @param dnLocation 上下位关系中,下位关系那一列
 * @param node 目标节点
 * @param rootNode 根节点
 * @return 层数。
 */
@SuppressWarnings("unchecked")
public static int findLayer(ArrayList<String> upLocation, ArrayList<String> dnLocation, String node, String rootNode){

	int layer = 0;
	if(node.equals(rootNode)) return layer;
	boolean findroot = false;
	ArrayList<String> nodePre = new ArrayList<>();
	ArrayList<String> nodeNow = new ArrayList<>();
	HashSet<String> findedNode = new HashSet<>();
	nodePre.add(node);
	findedNode.add(node);
	while(!findroot)
	{
		layer++;
		for(int i = 0; i < upLocation.size(); i++)
		{
			for(int j = 0; j < nodePre.size(); j++)
			{
				if (dnLocation.get(i).equals(nodePre.get(j))) {
					if(findedNode.contains(upLocation.get(i))){
						continue;
					}
					if(upLocation.get(i).equals(rootNode)) {
						findroot = true;
						break;
						}
					else {
						nodeNow.add(upLocation.get(i));
						findedNode.add(upLocation.get(i));
					}
				}
			}
			if(findroot) {
				break;
			}
		}
		nodePre = (ArrayList<String>) nodeNow.clone();
		nodeNow = new ArrayList<>();
	}
	return layer;
}
 
Example 20
Project: jaer   File: AERFile.java   View Source Code Vote up 3 votes
public static void filterPolarity(ArrayList<PSPInput> arr,boolean polarity)
{
    ArrayList<PSPInput> all=(ArrayList<PSPInput>) arr.clone();
    
    arr.clear();
    
    int pol=polarity?1:-1;
    
    for(PSPInput ev:all)
        if(ev.sp.act==pol)
            arr.add(ev);
    
}