本文整理匯總了Java中java.util.ArrayList.clone方法的典型用法代碼示例。如果您正苦於以下問題:Java ArrayList.clone方法的具體用法?Java ArrayList.clone怎麽用?Java ArrayList.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.ArrayList
的用法示例。
在下文中一共展示了ArrayList.clone方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: apply
import java.util.ArrayList; //導入方法依賴的package包/類
@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;
}
示例2: getSetInfos
import java.util.ArrayList; //導入方法依賴的package包/類
/**
* 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;
}
}
示例3: Person
import java.util.ArrayList; //導入方法依賴的package包/類
/**
* @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 = "";
}
示例4: createOutputColumns
import java.util.ArrayList; //導入方法依賴的package包/類
@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();
}
示例5: MultivariateGaussianMixture
import java.util.ArrayList; //導入方法依賴的package包/類
/**
* 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);
}
}
示例6: GaussianMixture
import java.util.ArrayList; //導入方法依賴的package包/類
/**
* 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);
}
}
示例7: findDistToLeaf
import java.util.ArrayList; //導入方法依賴的package包/類
/**
* 用於找到一個節點在領域樹中距離葉子節點還有幾層
* @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;
}
示例8: CodeSuggestAdapter
import java.util.ArrayList; //導入方法依賴的package包/類
@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();
}
示例9: BasicCompletionAdapter
import java.util.ArrayList; //導入方法依賴的package包/類
@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);
}
示例10: initData
import java.util.ArrayList; //導入方法依賴的package包/類
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();
}
}
示例11: cloneCollection
import java.util.ArrayList; //導入方法依賴的package包/類
/**
*
*/
@SuppressWarnings("unchecked")
public ArrayList<V> cloneCollection(ArrayList<V> collection) {
return (ArrayList<V>)collection.clone();
}
示例12: ViewCluster
import java.util.ArrayList; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public ViewCluster(ArrayList<View> views, ItemConfiguration config) {
this.views = (ArrayList<View>) views.clone();
this.config = config;
resetEdges();
}
示例13: PublisherRunner
import java.util.ArrayList; //導入方法依賴的package包/類
/**
* @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();
}
示例14: findParent
import java.util.ArrayList; //導入方法依賴的package包/類
/**
* 用於找到一個特定節點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;
}
示例15: handleMessage
import java.util.ArrayList; //導入方法依賴的package包/類
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)));
}
}