当前位置: 首页>>代码示例>>Java>>正文


Java Collections.copy方法代码示例

本文整理汇总了Java中java.util.Collections.copy方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.copy方法的具体用法?Java Collections.copy怎么用?Java Collections.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Collections的用法示例。


在下文中一共展示了Collections.copy方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: disconnectPreviousNodes

import java.util.Collections; //导入方法依赖的package包/类
private void disconnectPreviousNodes(final IGraphNode node) {
	final List<IGraphNode> list = new ArrayList<IGraphNode>(
			node.getPreviousNodes());
	Collections.copy(list, node.getPreviousNodes());
	for (final IGraphNode pNode : list) {
		node.removePreviousNode(pNode);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:9,代码来源:GenericGraphNode.java

示例2: disconnectFollowingNodes

import java.util.Collections; //导入方法依赖的package包/类
private void disconnectFollowingNodes(final IGraphNode node) {
	final List<IGraphNode> list = new ArrayList<IGraphNode>(
			node.getFollowingNodes());
	Collections.copy(list, node.getFollowingNodes());
	for (final IGraphNode fNode : list) {
		node.removeFollowingNode(fNode);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:9,代码来源:GenericGraphNode.java

示例3: disconnectPreviousNodes

import java.util.Collections; //导入方法依赖的package包/类
private void disconnectPreviousNodes(IGraphNode node) {
	List<IGraphNode> list = new ArrayList<IGraphNode>(
			node.getPreviousNodes());
	Collections.copy(list, node.getPreviousNodes());
	for (IGraphNode pNode : list) {
		node.removePreviousNode(pNode);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:9,代码来源:GenericGraphNode.java

示例4: disconnectFollowingNodes

import java.util.Collections; //导入方法依赖的package包/类
private void disconnectFollowingNodes(IGraphNode node) {
	List<IGraphNode> list = new ArrayList<IGraphNode>(
			node.getFollowingNodes());
	Collections.copy(list, node.getFollowingNodes());
	for (IGraphNode fNode : list) {
		node.removeFollowingNode(fNode);
	}
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:9,代码来源:GenericGraphNode.java

示例5: main

import java.util.Collections; //导入方法依赖的package包/类
public static void main(String[] args)
{
   // create and display a List< Character >
   Character[] letters = {'P', 'C', 'M'};
   List<Character> list = Arrays.asList(letters); // get List
   System.out.println("list contains: ");
   output(list);

   // reverse and display the List<Character>
   Collections.reverse(list); // reverse order the elements
   System.out.printf("%nAfter calling reverse, list contains:%n");
   output(list);

   // create copyList from an array of 3 Characters
   Character[] lettersCopy = new Character[3]; 
   List<Character> copyList = Arrays.asList(lettersCopy); 

   // copy the contents of list into copyList
   Collections.copy(copyList, list);
   System.out.printf("%nAfter copying, copyList contains:%n");
   output(copyList);

   // fill list with Rs 
   Collections.fill(list, 'R'); 
   System.out.printf("%nAfter calling fill, list contains:%n");
   output(list);
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:28,代码来源:Algorithms1.java

示例6: test

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void test(){

    List<String> src = new ArrayList<>();
    src.add("asd");
    List<String> dest = new ArrayList<>(Arrays.asList(new String[src.size()]));
    Collections.copy(dest,src);
    System.out.println(dest);

}
 
开发者ID:werewolfKill,项目名称:werewolf_server,代码行数:11,代码来源:ListTest.java

示例7: getDataTypeListCopy

import java.util.Collections; //导入方法依赖的package包/类
private static List<DataType> getDataTypeListCopy(List<DataType> dataTypeList) {
	List<DataType> dataTypeListCopy = new ArrayList<DataType>();
	for(int i = 0; i<dataTypeList.size(); i++){
		dataTypeListCopy.add(null);
	}
	Collections.copy(dataTypeListCopy, dataTypeList);
	return dataTypeListCopy;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:9,代码来源:DataType.java

示例8: resumeSuggestionOnLastComposedWord

import java.util.Collections; //导入方法依赖的package包/类
public void resumeSuggestionOnLastComposedWord(final LastComposedWord lastComposedWord) {
    mEvents.clear();
    Collections.copy(mEvents, lastComposedWord.mEvents);
    mInputPointers.set(lastComposedWord.mInputPointers);
    mCombinerChain.reset();
    refreshTypedWordCache();
    mCapitalizedMode = lastComposedWord.mCapitalizedMode;
    mAutoCorrection = null; // This will be filled by the next call to updateSuggestion.
    mCursorPositionWithinWord = mCodePointSize;
    mRejectedBatchModeSuggestion = null;
    mIsResumed = true;
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:13,代码来源:WordComposer.java

示例9: main

import java.util.Collections; //导入方法依赖的package包/类
public static void main(String[] args) {

    //create first Vector object
    Vector v1 = new Vector();

    //Add elements to Vector
    v1.add("1");
    v1.add("2");
    v1.add("3");

    //create another Vector object
    Vector v2 = new Vector();

    //Add elements to Vector
    v2.add("One");
    v2.add("Two");
    v2.add("Three");
    v2.add("Four");
    v2.add("Five");

    /*
      To copy elements of one Java Vector to another use,
      static void copy(List dstList, List sourceList) method of Collections class.

      This method copies all elements of source list to destination list. After copy
      index of the elements in both source and destination lists would be identical.

      The destination list must be long enough to hold all copied elements. If it is
      longer than that, the rest of the destination list's elments would remain
      unaffected.
    */

    System.out.println("Before copy, Second Vector Contains : " + v2);

    //copy all elements of Vector to another Vector using copy
    //method of Collections class
    Collections.copy(v2, v1);

    /*
      Please note that, If destination Vector object is not long enough
      to hold all elements of source Vector,
      it throws IndexOutOfBoundsException.
    */

    System.out.println("After copy, Second Vector Contains : " + v2);
  }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:47,代码来源:CopyElementsOfVectorToVectorExample.java

示例10: main

import java.util.Collections; //导入方法依赖的package包/类
public static void main(String[] args) {

    //create a Vector object
    Vector v = new Vector();

    //Add elements to Vector
    v.add("1");
    v.add("2");
    v.add("3");

    //create an ArrayList object
    ArrayList arrayList = new ArrayList();

    //Add elements to Arraylist
    arrayList.add("One");
    arrayList.add("Two");
    arrayList.add("Three");
    arrayList.add("Four");
    arrayList.add("Five");

    /*
      To copy elements of Java Vector to Java ArrayList use,
      static void copy(List dstList, List sourceList) method of Collections class.

      This method copies all elements of source list to destination list. After copy
      index of the elements in both source and destination lists would be identical.

      The destination list must be long enough to hold all copied elements. If it is
      longer than that, the rest of the destination list's elments would remain
      unaffected.
    */

    System.out.println("Before copy ArrayList Contains : " + arrayList);

    //copy all elements of Vector to ArrayList using copy method of Collections class
    Collections.copy(arrayList, v);

    /*
      Please note that, If ArrayList is not long enough to hold all elements of
      Vector, it throws IndexOutOfBoundsException.
    */

    System.out.println("After Copy ArrayList Contains : " + arrayList);
  }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:45,代码来源:CopyElementsOfVectorToArrayListExample.java

示例11: main

import java.util.Collections; //导入方法依赖的package包/类
public static void main(String[] args) {
  //create an ArrayList object
  ArrayList arrayList = new ArrayList();

  //Add elements to Arraylist
  arrayList.add("1");
  arrayList.add("4");
  arrayList.add("2");
  arrayList.add("5");
  arrayList.add("3");

  //create a Vector object
  Vector v = new Vector();

  //Add elements to Vector
  v.add("A");
  v.add("B");
  v.add("D");
  v.add("E");
  v.add("F");
  v.add("G");
  v.add("H");

  /*
    To copy elements of Java ArrayList to Java Vector use,
    static void copy(List dstList, List sourceList) method of Collections class.

    This method copies all elements of source list to destination list. After copy
    index of the elements in both source and destination lists would be identical.

    The destination list must be long enough to hold all copied elements. If it is
    longer than that, the rest of the destination list's elments would remain
    unaffected.
  */

  System.out.println("Before copy, Vector Contains : " + v);

  //copy all elements of ArrayList to Vector using copy method of Collections class
  Collections.copy(v, arrayList);

  /*
     Please note that, If Vector is not long enough to hold all elements of
     ArrayList, it throws IndexOutOfBoundsException.
  */

  System.out.println("After Copy, Vector Contains : " + v);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:48,代码来源:CopyElementsOfArrayListToVectorExample.java

示例12: main

import java.util.Collections; //导入方法依赖的package包/类
public static void main(String[] args) {

    //create first ArrayList object
    ArrayList arrayList1 = new ArrayList();

    //Add elements to ArrayList
    arrayList1.add("1");
    arrayList1.add("2");
    arrayList1.add("3");

    //create another ArrayList object
    ArrayList arrayList2 = new ArrayList();

    //Add elements to Arraylist
    arrayList2.add("One");
    arrayList2.add("Two");
    arrayList2.add("Three");
    arrayList2.add("Four");
    arrayList2.add("Five");

    /*
      To copy elements of one Java ArrayList to another use,
      static void copy(List dstList, List sourceList) method of Collections class.

      This method copies all elements of source list to destination list. After copy
      index of the elements in both source and destination lists would be identical.

      The destination list must be long enough to hold all copied elements. If it is
      longer than that, the rest of the destination list's elments would remain
      unaffected.
    */

    System.out.println("Before copy, Second ArrayList Contains : " + arrayList2);

    //copy all elements of ArrayList to another ArrayList using copy
    //method of Collections class
    Collections.copy(arrayList2, arrayList1);

    /*
      Please note that, If destination ArrayList object is not long
      enough to hold all elements of source ArrayList,
      it throws IndexOutOfBoundsException.
    */

    System.out.println("After copy, Second ArrayList Contains : " + arrayList2);
  }
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:47,代码来源:CopyElementsOfArrayListToArrayListExample.java

示例13: EpisodeRecyclerAdapter

import java.util.Collections; //导入方法依赖的package包/类
public EpisodeRecyclerAdapter(Context context, List<Episode> episodes, OnItemClickListener itemClickListener) {
    this.context = context;
    this.itemClickListener = itemClickListener;
    list = episodes;
    Collections.copy(list, result);
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:7,代码来源:EpisodeRecyclerAdapter.java

示例14: getDeepCopyOf

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Returns a deep copy of the given list.
 * 
 * @param <T> the type of the list to copy
 * 
 * @param listToCopy the list to copy
 * @return a copy of the given list
 */
public static <T> List<T> getDeepCopyOf(List<T> listToCopy) {
   List<T> copy = new ArrayList<>(listToCopy);
   Collections.copy(copy, listToCopy);
   return copy;
}
 
开发者ID:Intelligent-Systems-Group,项目名称:jpl-framework,代码行数:14,代码来源:CollectionsUtils.java


注:本文中的java.util.Collections.copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。