本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}