copy

How to copy a “Dictionary” in Swift?

百般思念 提交于 2019-12-18 14:13:30
问题 How to copy a "Dictionary" in Swift? That is, get another object with same keys/values but different memory address. Furthermore, how to copy an object in Swift? Thanks, 回答1: A 'Dictionary' is actually a Struct in swift, which is a value type. So copying it is as easy as: let myDictionary = ... let copyOfMyDictionary = myDictionary To copy an object (which is a reference type) has a couple of different answers. If the object adopts the NSCopying protocol, then you can just do: let myObject =

How does the internal implementation of memcpy work?

霸气de小男生 提交于 2019-12-18 14:08:14
问题 How does the standard C function 'memcpy' work? It has to copy a (large) chunk of RAM to another area in the RAM. Since I know you cannot move straight from RAM to RAM in assembly (with the mov instruction) so I am guessing it uses a CPU register as the intermediate memory when copying? But how does it copy? By blocks (how would it copy by blocks?), by individual bytes (char) or the largest data type they have (copy in long long double's - which is 12 bytes on my system). EDIT: Ok apparently

In chrome, using the window.Clipboard object, is there a way to capture pasted text?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 13:16:39
问题 You can capture an image. I am trying to figure out how to capture text. I'm guessing there isn't, for security reasons, but I wanted to make sure. Also is there a reference for this stuff? window.Clipboard object isn't part of the v8 engine, it's a part of the chrome browser and I can't find official documentation for it. 回答1: In the code you linked there is a pasteHandler function with the following: // Get the items from the clipboard var items = e.clipboardData.items; if (items) { // Loop

“display:none” content copied to clipboard, visible when pasted

荒凉一梦 提交于 2019-12-18 13:09:49
问题 I'm having a problem with non-displayed HTML elements being copied to the clipboard, and then displayed when the content is pasted into MS Word, Outlook, etc. For example: <p>Hello</p> <p style="display: none;">I'm Hidden</p> <p>World</p> If I view that HTML in a browser, copy the text to my clipboard, then paste into Outlook, the middle paragraph remains hidden. Good news. However, in this example: <p>Hello</p> <input type="text" value="I'm not hidden" style="display: none;" /> <p>World</p>

Copy one string array to another

霸气de小男生 提交于 2019-12-18 12:20:22
问题 How can I copy a string[] from another string[] ? Suppose I have string[] args . How can I copy it to another array string[] args1 ? 回答1: Allocate space for the target array, that use Array.CopyTo(): targetArray = new string[sourceArray.Length]; sourceArray.CopyTo( targetArray, 0 ); 回答2: To create a completely new array with the same contents (as a shallow copy): call Array.Clone and just cast the result. To copy a portion of a string array into another string array: call Array.Copy or Array

PG COPY error: invalid input syntax for integer

試著忘記壹切 提交于 2019-12-18 11:47:06
问题 Running COPY results in ERROR: invalid input syntax for integer: "" error message for me. What am I missing? My /tmp/people.csv file: "age","first_name","last_name" "23","Ivan","Poupkine" "","Eugene","Pirogov" My /tmp/csv_test.sql file: CREATE TABLE people ( age integer, first_name varchar(20), last_name varchar(20) ); COPY people FROM '/tmp/people.csv' WITH ( FORMAT CSV, HEADER true, NULL '' ); DROP TABLE people; Output: $ psql postgres -f /tmp/sql_test.sql CREATE TABLE psql:sql_test.sql:13:

Cleanest way to copy a constant size array in c++11

浪子不回头ぞ 提交于 2019-12-18 11:17:56
问题 I often find myself wanting to copy the contents of arrays that have a constant size, I usually just write something along the lines of: float a[4] = {0,1,2,3}; float b[4]; for(int i=0; i<4; i++){ b[i]=a[i]; } As of lately, I am writing a linear calculus library for educational purposes, and I was wondering if there was a better way to do it. The first thing that came to my mind, was using memcpy: memcpy(b, a, sizeof(float) * 4); But this seems very c-like and error prone to me. I like having

What's the use of System.String.Copy in .NET?

☆樱花仙子☆ 提交于 2019-12-18 10:58:40
问题 I'm afraid that this is a very silly question, but I must be missing something. Why might one want to use String.Copy(string)? The documentation says the method Creates a new instance of String with the same value as a specified String. Since strings are immutable in .NET, I'm not sure what's the benefit of using this method, as I'd think that string copy = String.Copy(otherString); would for all practical purposes seem to yield the same result as string copy = otherString; That is, except

python copy files to a network location on Windows without mapping a drive

 ̄綄美尐妖づ 提交于 2019-12-18 10:55:39
问题 I am running python in a non interactive session on windows and therefore I cannot map a network drive. Most of what I have researched on here and through google everyone suggests mapping a network drive and copying the files that way. On linux I would facilitate this with an smbmount but unfortunately the software I am working with is tied to windows. Are there any options for interacting with files via a UNC path? 回答1: Personally, I've never had difficulties getting Python to simply

Dockerfile copy keep subdirectory structure

China☆狼群 提交于 2019-12-18 09:59:38
问题 I'm trying to copy a number of files and folders to a docker image build from my localhost. The files are like this: folder1 file1 file2 folder2 file1 file2 I'm trying to make the copy like this: COPY files/* /files/ However, all files are placed in /files/ is there a way in Docker to keep the subdirectory structure as well as copying the files into their directories? 回答1: Remove star from COPY, with this Dockerfile: FROM ubuntu COPY files/ /files/ RUN ls -la /files/* Structure is there: $