structure

How to structure api calls in Vue.js?

旧巷老猫 提交于 2019-12-03 02:54:23
问题 I'm currently working on a new Vue.js application. It depends heavily on api calls to my backend database. For a lot of things I use Vuex stores because it manages shared data between my components. When looking at other Vue projects on github I see a special vuex directory with files that handles all the actions, states and so on. So when a component has to call the API, it includes the actions file from the vuex directory. But, for messages for example, I don't want to use Vuex because

Haskell shying away from probabilistic data structures?

心不动则不痛 提交于 2019-12-03 02:43:38
If you search for skips lists implemented in Haskell, you won't find many. It is a probabilistic data structure needing a random number generator, meaning that any of these structures would need to run in the IO monad. Are Haskell folks staying away from these data structures because it's not possible to implement them purely? How can Haskell deal with them? A pseudo-random number generator can of course be used outside of IO , by simply storing the current generator value along with the probabilistic pure data structure and updating it when constructing modified versions. The downside to this

Can I define a function inside a C structure? [duplicate]

ε祈祈猫儿з 提交于 2019-12-03 01:19:53
问题 This question already has answers here : Define functions in structs (8 answers) Closed 3 years ago . I am trying to convert some C++ code to C and I am facing some problems. How can I define inside a structure a function? Like this: typedef struct { double x, y, z; struct Point *next; struct Point *prev; void act() {sth. to do here}; } Point; 回答1: No, you cannot define a function within a struct in C. You can have a function pointer in a struct though but having a function pointer is very

How do You structure an iPhone Xcode project?

青春壹個敷衍的年華 提交于 2019-12-03 00:53:39
问题 What are good ways of building groups/folders? I've tried by feature (UI for a feature plus model etc) with a common group. I've also tried by UI, model, etc. The former keeps like things together which fits the iPhone paradigm nicely. The latter means I jump around a bit more. What do you think? 回答1: The standard Xcode MVC folder structure is as follows. CoreData : Contains DataModel and Entity Classes. Extension : Contain One class(default apple class extensions+project class extensions.)

How do I load example datasets in R?

人走茶凉 提交于 2019-12-02 22:26:32
Let's say I want to reproduce an example posted on StackOverflow. Some have suggested posters use dput() to help streamline this process or one of the datasets available in the base package . In this case, however, suppose I have only been given the output of the dataframe: > site.data site year peak 1 ALBEN 5 101529.6 2 ALBEN 10 117483.4 3 ALBEN 20 132960.9 8 ALDER 5 6561.3 9 ALDER 10 7897.1 10 ALDER 20 9208.1 15 AMERI 5 43656.5 16 AMERI 10 51475.3 17 AMERI 20 58854.4 Do I have other options besides saving this as a text file and using read.table() ? Shane That's a neat solution. I'm guessing

Lock free & Thread-Safe IList<T> for .NET

断了今生、忘了曾经 提交于 2019-12-02 20:51:20
Is there a lock-free & thread-safe data structure that implements IList? Naturally by lock-free I mean an implementation that makes no use of locking primitives in .NET but rather uses interlocked operations / atomic operations to achieve thread safety... There isn't one, apparently under the concurrent data structures... Has anyone seen one floating around? I've seen a java one implemented in amino-cbbs , called LockFreeVector but nothing for .NET so far. Any ideas? Well, I couldn't find such a class anywhere; so I gave it a shot . The source code for my ConcurrentList<T> class is available

Does storing a lot of images in a single directory slow down image retrieval?

耗尽温柔 提交于 2019-12-02 20:47:24
If i have a site where users can upload as many images as they want(think photobucket-like), what is the best way to set up file storage (also, all uploads get a unique random timestamp)? site root --username ----image1.jpg ----image2.jpg ----image3.jpg --anotheruser ----image1.jpg ----image2.jpg ----image3.jpg ... or siteroot --uploads ----image1.jpg ----image2.jpg ----image3.jpg ----image4.jpg ----image6.jpg ... ----image50000.jpg I think the first method is more organized. But i think the second method is standard(keeping all uploads in the same dir), but i wonder if it would be slower when

How to return a struct from a function in C++?

旧城冷巷雨未停 提交于 2019-12-02 20:22:34
I've tried on a few different forums and can't seem to get a straight answer, how can I make this function return the struct? If I try 'return newStudent;' I get the error 'No suitable user-defined conversion from studentType to studentType exists.' // Input function studentType newStudent() { struct studentType { string studentID; string firstName; string lastName; string subjectName; string courseGrade; int arrayMarks[4]; double avgMarks; } newStudent; cout << "\nPlease enter student information:\n"; cout << "\nFirst Name: "; cin >> newStudent.firstName; cout << "\nLast Name: "; cin >>

Is there a way to access individual bits with a union?

孤者浪人 提交于 2019-12-02 19:18:30
I am writing a C program. I want a variable that I can access as a char but I can also access the specific bits of. I was thinking I could use a union like this... typedef union { unsigned char status; bit bits[8]; }DeviceStatus; but the compiler doesn't like this. Apparently you can't use bits in a structure. So what can I do instead? Sure, but you actually want to use a struct to define the bits like this typedef union { struct { unsigned char bit1 : 1; unsigned char bit2 : 1; unsigned char bit3 : 1; unsigned char bit4 : 1; unsigned char bit5 : 1; unsigned char bit6 : 1; unsigned char bit7 :

input_event structure description (from linux/input.h)

眉间皱痕 提交于 2019-12-02 19:03:52
Can someone please tell me what are the properties of the datatypes used by the input_event structure? It is defined as follows in the input.h file: struct input_event { struct timeval time; __u16 type; __u16 code; __s32 value; }; but there are no other descriptions! Even googling gave me nothing interesting. The only thing I know is that time gives seconds or miliseconds from epoch and value gives code of pressed button. But even value of value property isn't really clear for me. In my program every keystroke generates six events. Following events are response for pressing ENTER key: type=4