copy

Need of a faster array copy

爷,独闯天下 提交于 2019-12-23 09:39:08
问题 After doing a bit of reading, I discovered that there are some differences in the ways you can copy arrays in java. For my application I have a recursive tree of nodes, each containing a 2d board array (8x8). Through profiler testing, the best thing I could come up with is the java.util.Arrays.copyOf(array) method, which uses the native System.arraycopy. Even with this, I am spending 80% of my time creating new arrays. If anyone has any ideas on how to speed this up I'd appreciate it. Perhaps

.NET - Copy from Unmanaged Array to Unmanaged Array

元气小坏坏 提交于 2019-12-23 09:15:14
问题 I've been looking through the Marshal class, but I can't seem to find a method that allows me to copy from an unmanaged array (IntPtr) to another unmanaged array (IntPtr). Is this possible using .NET? 回答1: You can also DllImport RtlMoveMemory to get the job done: [DllImport("Kernel32.dll", EntryPoint="RtlMoveMemory", SetLastError=false)] static extern void MoveMemory(IntPtr dest, IntPtr src, int size); This will also require FullTrust, however, but as you are working with unmanaged code, I'd

How to create copy of file using StreamReader and StreamWriter

喜你入骨 提交于 2019-12-23 09:11:09
问题 I need to use StreamReader to read a .txt file on a console application, then create a new file or backup with a different name but same content. The problem is i cant figure out how to use the content from the first file to place into the new one. (This is for a school thing and im new to C#) using System; using System.IO; namespace UserListCopier { class Program { static void Main() { string fineName = "zombieList.txt"; StreamReader reader = new StreamReader(fineName); int lineNumber = 0;

How to copy a file to a specific folder in a Python script? [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-23 08:07:54
问题 This question already has answers here : How do I copy a file in Python? (16 answers) Closed 2 years ago . I have the path of a file stored in a variable (say) filePath. I would like to copy that particular file to another specific folder within a Python script. I tried folderPath = (os.getcwd() + "/folder_name/") #to get the path of the folder shutil.copyfile(filePath, folderPath) But I got an error IOError: [Errno 21] Is a directory . How can I solve this ? My question might seem to be a

First bracketed assignment is as time-consuming as full assignment?

偶尔善良 提交于 2019-12-23 07:56:06
问题 Regarding this answer in: What exactly is copy-on-modify semantics in R, and where is the canonical source? We can see that, at the first time a vector is altered with '[<-' , R copies the entire vector even if only a single entry is to be modifed. At the second time, however, the vector is altered "in place". This is noticeable without inspecting the address of the objects if we measure the time to create and modify a large vector: > system.time(a <- rep(1L, 10^8)) user system elapsed 0.15 0

vim system register * and + not working

江枫思渺然 提交于 2019-12-23 07:28:07
问题 :echo has('clipboard') returns 1, but whenever I execute "+yy" or "*yy" nothing seems to be in those registers. If I use regular yy to copy another line of text, then try to paste from the register using CONTROL+V nothing happens. If I try "+p vim pastes the line of text I copied using the regular yy command. What's going on here? I'm on FreeBSD by the way. 回答1: Your vim version may not be compiled with X11 clipboard integration. In vim run the :version command and look for xterm_clipboard in

Applescript Copy file to a new folder

℡╲_俬逩灬. 提交于 2019-12-23 07:26:25
问题 I need to create an AppleSript that will copy specified files from one folder to a newly created folder. These files need to be specified in the AppleScript editor so something like: start fileToBeMoved = "Desktop/Test Folder 1/test.doc" newfoldername = "Test Folder 2" make newfolder and name it 'newfoldername' copy 'fileToBeMoved' to 'newfolder' end 回答1: Generally: tell application "Finder" make new folder at alias "Macintosh HD:Users:user:Desktop:" with properties {name:"Test Folder 2"}

Applescript Copy file to a new folder

寵の児 提交于 2019-12-23 07:25:14
问题 I need to create an AppleSript that will copy specified files from one folder to a newly created folder. These files need to be specified in the AppleScript editor so something like: start fileToBeMoved = "Desktop/Test Folder 1/test.doc" newfoldername = "Test Folder 2" make newfolder and name it 'newfoldername' copy 'fileToBeMoved' to 'newfolder' end 回答1: Generally: tell application "Finder" make new folder at alias "Macintosh HD:Users:user:Desktop:" with properties {name:"Test Folder 2"}

C++ Deep Copy Vector Pointer Object

自作多情 提交于 2019-12-23 07:00:54
问题 I have a class called Heap that is a Vector of pointers to HeapItem objects vector<HeapItem*> myHeap; I want to create a deep copy of Heap so that I can delete all the items in the copy without affecting the original Heap. EX: OriginalHeap = new Heap(); OriginalHeap.Insert(HeapItem1); OriginalHeap.Insert(HeapItem2); OriginalHeap.Insert(HeapItem3); CopyHeap = OriginalHeap; CopyHeap.deleteMin(); print(OriginalHeap); print(CopyHeap); Output: OriginalHeap = HeapItem1,HeapItem2,HeapItem3 CopyHeap

Java copy section of array

心已入冬 提交于 2019-12-23 06:49:34
问题 Is there a method that will copy a section of an array(not arraylist) and make a new array from it? Example: [1,2,3,4,5] and you create a new array from it: [1,2,3] Are there any one line/methods that will do this? 回答1: Here's a java 1.4 compatible 1.5-liner: int[] array = { 1, 2, 3, 4, 5 }; int size = 3; int[] part = new int[size]; System.arraycopy(array, 0, part, 0, size); You could do this in one line, but you wouldn't have a reference to the result. To make a one-liner, you could refactor