structure

Why is DateTime a structure in .Net?

我们两清 提交于 2019-12-04 23:19:32
Why is DateTime a structure instead of an inheritable class? (I would like to be able to override the ToString() method but I can't.) Probably because it was seen as a small, simple and immutable data structure, much like an integer or decimal. Making it a struct under these conditions make using a DateTime very efficient. If it had been made a class, this efficiency benefit would have been lost because that would require memory allocations every time you create a new DateTime. Besides, how many variant forms of a DateTime can you come up with? (Ignoring the allternate ToString implementations

Component without template

风格不统一 提交于 2019-12-04 23:06:44
I have a bit of code that makes an api call to a server and returns some JSON. It did exist as a method in my component but as it is getting a bit long I want to extract it to it's own file In vuejs what is the best practice here. should it be a component without a template? How would this work? will I just create an es6 module? skribe I would suggest using a mixin here. In a file like myCoolMixin.js define your mixin... export default { methods: { myAwesomMethod() { //do something cool... } } } You can define anything in a mixin just like a component. e.g. data object, computed or watched

Is this a decent structure for a multithreaded videocoacher program?

柔情痞子 提交于 2019-12-04 20:19:03
Hi I’m currently working on a project for a videocoacher program for recording and replaying video, as well as showing delayed real-time video, and tracking placement via color. The software is running on linux , on a 4 core odroid, and initially I started to make it multi threaded with threads implemented as a part of each new class. Each of these threads taking care of their own gui elements. I’ve later found out that I need to show all gui elements/video in the main/gui thread. Earlier I’ve used opencv and boost. But it seems like using the Qt might be a better idea since some of the code

Coldfusion - How to loop through an Array of Structure and print out dynamically all KEY values?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 17:43:25
问题 Giving the Array of Structure below: I am able to print out all values from all fields by doing: <cfset ColumnNames = structKeyArray(ApiData[1])> <cfset ColumnLength = ArrayLen(ColumnNames)> <cfloop from="1" to="#ArrayLen(ApiData)#" index="i"> <cfdump var="#ApiData[i].Created#"> <cfdump var="#ApiData[i].Name#"> ...and so on Now I am trying to loop through all fields so that I dont have to actually write the name of each field. How do I do this dynamically? Something like: <cfloop from="1" to=

Filter values from list in R

蹲街弑〆低调 提交于 2019-12-04 17:41:58
问题 I want to calculate the mean of a list of named numbers. There are numeric(0) values that I first want to remove. Also, I would like to retrieve which elements of the list contain numeric(0) values. Here is an example how the values could look like: >r["gg",] $`01_1_er` gg 0.5176445 $`02_1_er` gg 0.4990959 $`03_1_er` gg 0.5691489 $`22_1_er` numeric(0) $`23_1_er` numeric(0) $`25_1_er` gg 0.386304 And here is the result of str: > str(r["gg",]) List of 6 $ 01_1_er: Named num 0.518 ..- attr(*,

Is it guaranteed that the padding bits of “zeroed” structure will be zeroed in C?

独自空忆成欢 提交于 2019-12-04 17:33:31
This statement in the article made me embarrassed: C permits an implementation to insert padding into structures (but not into arrays) to ensure that all fields have a useful alignment for the target. If you zero a structure and then set some of the fields, will the padding bits all be zero? According to the results of the survey, 36 percent were sure that they would be, and 29 percent didn't know. Depending on the compiler (and optimization level), it may or may not be . It was not completely clear, so I turned to the standard. The ISO/IEC 9899 in §6.2.6.1 states: When a value is stored in an

Marshal.SizeOf error in computing size

别说谁变了你拦得住时间么 提交于 2019-12-04 13:59:08
i have a structure public struct SERVER_USB_DEVICE { USB_HWID usbHWID; byte status; bool bExcludeDevice; bool bSharedManually; ulong ulDeviceId; ulong ulClientAddr; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] string usbDeviceDescr; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] string locationInfo; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] string nickName; } i am getting following error System.ArgumentException was unhandled Message="Type 'SERVER_USB_DEVICE' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed." at

Building Tensorflow Graphs Inside of Functions

戏子无情 提交于 2019-12-04 13:44:29
问题 I'm learning Tensorflow and am trying to properly structure my code. I (more or less) know how to build graphs either bare or as class methods, but I'm trying to figure out how best to structure the code. I've tried the simple example: def build_graph(): g = tf.Graph() with g.as_default(): a = tf.placeholder(tf.int8) b = tf.add(a, tf.constant(1, dtype=tf.int8)) return g graph = build_graph() with tf.Session(graph=graph) as sess: feed = {a: 3} print(sess.run(b, feed_dict=feed)) which should

Pass array of structs from Python to C

℡╲_俬逩灬. 提交于 2019-12-04 10:42:26
问题 [Update: Problem solved! See bottom of the post] I need to allow python developers to pass an array of packed data (in this case vertices) into my API, which is a series of C++ interfaces exposed manually through the Python C API. My initial impression with this is to use the ctypes Structure class to allow for an interface like this: class Vertex(Structure): _fields_ = [ ('x', c_float), ('y', c_float), ('z', c_float), ('u', c_float), ('v', c_float), ('color', c_int) ] verts = (Vertex * 3)()

SML: What's the difference between using abstype and using a signature to hide the implementation of a structure?

冷暖自知 提交于 2019-12-04 10:13:55
问题 I've done a little work in SML in the past, but I'm now starting to get to the more interesting parts. Using the abstype...with...end construct, I can make things but keep their implementation details hidden. I can also create a signature of the thing I want to make, and use the :> operator to make a structure adhering to that signature that keeps the implementation details hidden. Aren't signatures/structures just a more general version of abstypes? What can I do with abstypes that I can't