concatenation

Changing size of array in extension method does not work?

守給你的承諾、 提交于 2019-12-01 10:32:04
问题 So basically I wrote my little Add extension method for array types. using System; using System.Linq; public static class Extensions { public static void Add<T>(this T[] _self, T item) { _self = _self.Concat(new T[] { item }).ToArray(); } } public class Program { public static void Main() { string[] test = { "Hello" }; test = test.Concat(new string[] { "cruel" }).ToArray(); test.Add("but funny"); Console.WriteLine(String.Join(" ", test) + " world"); } } The output should be Hello cruel but

Why string concatenation takes so long time? [duplicate]

扶醉桌前 提交于 2019-12-01 09:27:49
问题 This question already has answers here : StringBuilder vs String concatenation in toString() in Java (18 answers) Closed 4 years ago . I am concatenating a String in a loop but it takes ages, why is that? for (String object : jsonData) { counter++; finalJsonDataStr += object; } Variable object is a piece of JSON, up to 70 chars and the loop goes approx 50k times. I understand some people advice StringBuffer or StringBuilder but this link says, it has no performance improvements: StringBuilder

Concatenating two std::vector — which method is more efficient and how/why?

笑着哭i 提交于 2019-12-01 09:26:01
Consider the following scenario: std::vector<int> A; std::vector<int> B; std::vector<int> AB; I want AB to have contents of A and then the contents of B in the same order. Approach 1: AB.reserve( A.size() + B.size() ); // preallocate memory AB.insert( AB.end(), A.begin(), A.end() ); AB.insert( AB.end(), B.begin(), B.end() ); Approach 2: std::vector<int> AB ( A.begin(), A.end() ); // calling constructor AB.insert ( AB.end(), B.begin(), B.end() ); Which one of the above methods is more efficient? Why? Is there a different method that is more efficient? I think the first one will always be faster

Concatenating All Columns of Each Record Into One Entry

冷暖自知 提交于 2019-12-01 09:25:50
问题 I am trying to extract the records of a table into a csv file. The SQL query is as simple as SELECT * FROM MY_TABLE_NAME which gives a hypothetical record set of A B C D E F G H I J K L What I want is a record set where all the columns are concatenated together, e.g. A, B, C, D E, F, G, H I, J, K, L I have been exposed to LISTAGG, but I do not want to aggregate records. I want to maintain each individual line entry's structure, just separated with a delimiter. Any thoughts? EDIT: I need to

DB2 Distinct + xmlagg Query

白昼怎懂夜的黑 提交于 2019-12-01 09:12:16
I want equivalent to GROUP_CONCAT functionality of MySql in DB2. I have tried XML Aggrigate functon of DB2 for cocating murows. SELECT a.ID, substr(xmlserialize(xmlagg(xmltext( concat(',', SPECIALISATION)))as varchar( 1024 )),2), substr(xmlserialize(xmlagg(xmltext(concat(',,, BASIC_SKILL2)))as varchar( 1024 )),2), substr(xmlserialize(xmlagg(xmltext(concat(',', BASIC_SKILL1)))as varchar( 1024 )),2) FROM candidate_resume_data a,candidate_skills_info b,skill_special_master c,skill_master_basic2 d,skill_master_basic1 e WHERE e.SKILL_BASIC1_ID = d.SKILL_BASIC1_ID AND b.ID = a.ID AND d.SKILL_BASIC2

concatenating strings in C

做~自己de王妃 提交于 2019-12-01 08:55:25
i was wondering if there was a way to add a value to a string, not like 1 + 1 = 2 but like 1 + 1 = 11. I think you need string concatenation: #include <stdio.h> #include <string.h> int main() { char str1[50] = "Hello "; char str2[] = "World"; strcat(str1, str2); printf("str1: %s\n", str1); return 0; } from: http://irc.essex.ac.uk/www.iota-six.co.uk/c/g6_strcat_strncat.asp To concatenate more than two strings, you can use sprintf, e.g. char buffer[101]; sprintf(buffer, "%s%s%s%s", "this", " is", " my", " story"); Try taking a look at the strcat API. With sufficient buffer space, you can add one

Python pandas: concat vertical and horizontal

◇◆丶佛笑我妖孽 提交于 2019-12-01 08:51:25
I am trying to concat two dataframe, horizontally. df2 contains 2 result variables for every observation in df1. df1.shape (242583, 172) df2.shape (242583, 2) My code is: Fin = pd.concat([df1, df2], axis= 1) But somehow the result is stacked in 2 dimensions: Fin.shape (485166, 174) What am I missing here? There are different index values, so indexes are not aligned and get NaN s: df1 = pd.DataFrame({ 'A': ['a','a','a'], 'B': range(3) }) print (df1) A B 0 a 0 1 a 1 2 a 2 df2 = pd.DataFrame({ 'C': ['b','b','b'], 'D': range(4,7) }, index=[5,7,8]) print (df2) C D 5 b 4 7 b 5 8 b 6 Fin = pd.concat(

Sybase: How do I concatenate rows in sybase column

你离开我真会死。 提交于 2019-12-01 08:33:40
问题 I have a table with ID and Dept. Table is id dept salary date 1 30 2000 8/25/2015 12:06:54.870 PM 2 20 5500 7/12/2015 12:06:54.870 PM 3 30 6700 11/21/2013 12:06:54.870 PM 4 30 8900 4/16/2009 12:06:54.870 PM 5 30 9900 6/29/2014 12:06:54.870 PM 6 10 1120 7/3/2015 12:06:54.870 PM 7 20 8900 4/13/2013 12:06:54.870 PM 8 10 2400 7/23/2015 12:06:54.870 PM 9 30 2600 8/21/2015 12:06:54.870 PM 10 10 2999 8/3/2015 12:06:54.870 PM Just need the output like this Dept ID 30 1,3,4,5,9 回答1: This is the best

np.concatenate a ND tensor/array with a 1D array

只愿长相守 提交于 2019-12-01 08:32:05
I have two arrays a & b a.shape (5, 4, 3) array([[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0.10772717, 0.604584 , 0.41664413]], [[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0.10772717, 0.604584 , 0.41664413], [ 0.95879616, 0.85575133, 0.46135877]], [[ 0. , 0. , 0. ], [ 0.10772717, 0.604584 , 0.41664413], [ 0.95879616, 0.85575133, 0.46135877], [ 0.70442301, 0.74126523, 0.88965603]], [[ 0.10772717, 0.604584 , 0.41664413], [ 0.95879616, 0.85575133, 0.46135877], [ 0.70442301, 0.74126523, 0.88965603], [ 0.8039435 , 0.62802183, 0.58885027]], [[ 0.95879616, 0.85575133, 0.46135877], [ 0

how to use ffmpeg to apply 1:1 SAR before concat on large complex filter

孤者浪人 提交于 2019-12-01 08:21:09
问题 I use ffmpeg to concat videos in a fashion similar to this: I ran into a weird error with my inputs [Parsed_concat_0 @ 000000002a05bb80] Input link in10:v0 parameters (size 1280x720, SAR 2049:2048) do not match the corresponding output link in0:v0 parameters (1280x720, SAR 1:1) From what I've researched I need to use setsar to force all the videos to be 1:1 before I concat, but I'm not sure how to do that in my filter. 回答1: Add the setsar filter: ffmpeg -i 0.mp4 -i 1.mp4 -i 2.mp4 -filter