size

How can I change the size of an array in C?

匆匆过客 提交于 2019-11-27 14:24:38
I am experimenting a little bit with gamestudio. I am making now a shooter game. I have an array with the pointer's to the enemies. I want. to when an enemy is killed. remove him from the list. And I also want to be able to create new enemies. Gamestudio uses a scripting language named lite-C. It has the same syntax as C and on the website they say, that it can be compiled with any C compiler. It is pure C, no C++ or anything else. I am new to C. I normally program in .NET languages and some scripting languages, Once an array in C has been created, it is set. You need a dynamic data structure

Why class size depend only on data members and not on member functions?

Deadly 提交于 2019-11-27 14:03:20
I want to know the detail description on the size of a class. I want to know if there is only data members & member function without any virtual keyword then why the class size depends only on data members. For an eg: class A { int a; public: int display() { cout << "A=" << a << endl; } }; When I check the sizeof(A) i found that it is 4 byte. Why it is so? Why member function has no effect on the size of class A? Thanks Because the class's functions are not saved inside the object itself. Think of it in terms of C programming, every function of class A takes one secret parameter, the this

回溯法常见题目总结

风流意气都作罢 提交于 2019-11-27 13:44:15
1.电话号码的字母组合 题目描述: 给定一个仅包含数字 2-9 的字符串,返回所有它能表示的字母组合。 给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。 示例: 输入:"23" 输出:["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. 说明: 尽管上面的答案是按字典序排列的,但是你可以任意选择答案输出的顺序。 实现代码: class Solution { public: vector<string> letterCombinations(string digits) { if(digits == ""){ return res; } letter(digits,0,""); return res; } private: string lett[10] = { " ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }; vector<string>res; void letter(string digits,int index,string s){ if(index == digits.size()){ res.push_back(s); return; } char c = digits[index]; string

How to specify the size of the icon on the Marker in Google Maps V2 Android

六月ゝ 毕业季﹏ 提交于 2019-11-27 12:49:24
问题 In may app i use Map from Google Maps V2 and in this map i am trying to add markers each Marker with an icon, but the marker is taking the size of the icon which is making the icon looks flue. How can i specify the size of the marker in dp so that i can control how it looks like on the map 回答1: Currently i think we cannot change the marker size, so u can add marker image in drawable and re-size something like this:, int height = 100; int width = 100; BitmapDrawable bitmapdraw=(BitmapDrawable

ios 8 change the size of presented/modal view controller

两盒软妹~` 提交于 2019-11-27 12:45:56
问题 In ios 7 and before, I was updating the bounds of presentedViewController.view.superview to custom the size of presented view controller, but it seems this would not be the case in ios 8 any more. Since there is no superview can be set on the view controller(return nil when you try to call it in debugger). Any suggestions how to update the presented view controller's size? This would be used for the custom presentation transition. 回答1: I guess the following is easier and it works in iOS 8:

Java PriorityQueue with fixed size

纵饮孤独 提交于 2019-11-27 12:20:50
I am calculating a large number of possible resulting combinations of an algortihm. To sort this combinations I rate them with a double value und store them in PriorityQueue. Currently, there are about 200k items in that queue which is pretty much memory intesive. Acutally, I only need lets say the best 1000 or 100 of all items in the list. So I just started to ask myself if there is a way to have a priority queue with a fixed size in Java. I should behave like this: Is the item better than one of the allready stored? If yes, insert it to the according position and throw the element with the

How is stack size of process on linux related to pthread, fork and exec

六眼飞鱼酱① 提交于 2019-11-27 11:54:58
问题 I have a question about the stack size of a process on Linux. Is this stack size determined at linkage time and is coded in the ELF file? I wrote a program which prints its stack size by pthread_attr_getstacksize(&attr, &stacksize); . And if I run this program directly from a shell, it gives a value of about 10MB. But when I exec it from a thread which belongs to a multi-thread program, it gives a value of about 2MB. So I want to know what factors affect the stack size of a process which is

How to know bytes size of python object like arrays and dictionaries? - The simple way

一个人想着一个人 提交于 2019-11-27 11:53:57
问题 I was looking for a easy way to know bytes size of arrays and dictionaries object, like [ [1,2,3], [4,5,6] ] or { 1:{2:2} } Many topics say to use pylab, for example: from pylab import * A = array( [ [1,2,3], [4,5,6] ] ) A.nbytes 24 But, what about dictionaries? I saw lot of answers proposing to use pysize or heapy. An easy answer is given by Torsten Marek in this link: Which Python memory profiler is recommended?, but I haven't a clear interpretation about the output because the number of

What is the time complexity of a size() call on a LinkedList in Java?

家住魔仙堡 提交于 2019-11-27 11:53:56
问题 As the title asks, I wonder if the size() method in the LinkedList class takes amortized O(1) time or O(n) time. 回答1: It's O(1). You can google for the source code and you will come to such: From http://www.docjar.com/html/api/java/util/LinkedList.java.html All of the Collection classes I have looked at store a the size as a variable and don't iterate through everything to get it. 回答2: O(1) as you would have found had you looked at the source code... From LinkedList: private transient int

How to know the size of the string in bytes?

眉间皱痕 提交于 2019-11-27 11:31:23
I'm wondering if I can know how long in bytes for a string in C#, anyone know? You can use encoding like ASCII to get a character per byte by using the System.Text.Encoding class. or try this System.Text.ASCIIEncoding.Unicode.GetByteCount(string); System.Text.ASCIIEncoding.ASCII.GetByteCount(string); From MSDN : A String object is a sequential collection of System.Char objects that represent a string. So you can use this: var howManyBytes = yourString.Length * sizeof(Char); System.Text.ASCIIEncoding.Unicode.GetByteCount(yourString); Or System.Text.ASCIIEncoding.ASCII.GetByteCount(yourString);