gpt4 book ai didi

java - 将java中的arraylist转换为c

转载 作者:行者123 更新时间:2023-11-30 21:02:55 26 4
gpt4 key购买 nike

我在java中有一个像这样的数组列表:

public List<Integer> Data = Collections.synchronizedList (new ArrayList());

我想将它转换为c数组。

最佳答案

我假设您正在寻找用 C++ 创建一个线程安全(同步)ArrayList

取自:ArrayList::Synchronized Method

using namespace System;
using namespace System::Collections;
int main()
{

// Creates and initializes a new ArrayList instance.
ArrayList^ myAL = gcnew ArrayList;
myAL->Add( "The" );
myAL->Add( "quick" );
myAL->Add( "brown" );
myAL->Add( "fox" );

// Creates a synchronized wrapper around the ArrayList.
ArrayList^ mySyncdAL = ArrayList::Synchronized( myAL );

// Displays the sychronization status of both ArrayLists.
String^ szRes = myAL->IsSynchronized ? (String^)"synchronized" : "not synchronized";
Console::WriteLine( "myAL is {0}.", szRes );
String^ szSyncRes = mySyncdAL->IsSynchronized ? (String^)"synchronized" : "not synchronized";
Console::WriteLine( "mySyncdAL is {0}.", szSyncRes );
}

关于java - 将java中的arraylist转换为c,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27438480/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com