Questions tagged [structure]

Structure is a fundamental, tangible or intangible notion referring to the recognition, observation, nature, and permanence of patterns and relationships of entities. DO NOT USE this tag for C or C++ struct questions!

A structure can be a:

  • A structure in mathematical logic: in universal algebra and in model theory, a structure consists of a set along with a collection of finitary operations and relations which are defined on it.

  • The structure of a program

For the following topics, use different tags as indicated below:

  • A : a particular way of storing and organizing data in a computer so that it can be used efficiently.
  • A (short for "structure") is a keyword in the C and C++ languages, used to indicate a structures record.
6561 questions
28
votes
6 answers

What is so special about Monads?

A monad is a mathematical structure which is heavily used in (pure) functional programming, basically Haskell. However, there are many other mathematical structures available, like for example applicative functors, strong monads, or monoids. Some…
qznc
  • 1,113
  • 2
  • 12
  • 25
27
votes
2 answers

Component without template

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…
LeBlaireau
  • 17,133
  • 33
  • 112
  • 192
26
votes
3 answers

How to make a structure extern and define its typedef

I'm trying to implement tree algorithms in C. I have declared a extern struct in a header file that is completely independent (b_tree_ds.h). Now I plan to import the file in all source files that want to use this struct. So I must declare it using…
simar
  • 544
  • 2
  • 7
  • 15
26
votes
18 answers

How should I rewrite a very large compound if statement in C#?

In my C# code, I have an if statement that started innocently enough: if((something == -1) && (somethingelse == -1) && (etc == -1)) { // ... } It's growing. I think there must be 20 clauses in it now. How should I be handling this?
Michael Broschat
  • 875
  • 3
  • 10
  • 17
26
votes
4 answers

Files structure in MVVM (Android)

using MVVM or MVP should i name packages like model, viewmodel, view and put proper classes and interfaces there or is it just a logical structure that should not be visible in classes structure?
Jakub Kwiatek
  • 263
  • 1
  • 3
  • 6
26
votes
6 answers

Best structure for inventory database

I want to create a small database for my inventory but I have some problems on picking a structure. The inventory will be updated daily at the end of the day. The problem I am facing is the following. I have a table for my products, having an id,…
Saif Bechan
  • 16,551
  • 23
  • 83
  • 125
25
votes
7 answers

methods in constructors, bad?

I have a windows form, and I have a class that checks a text file to make sure it has certain aspect. Now I have methods in a constructor and it seems a little weird. Should I just leave the constructor blank, and implement a start() type method and…
Spooks
  • 6,937
  • 11
  • 49
  • 66
25
votes
2 answers

Is there an efficient way to share structure between golang packages?

I have a short program in Go with the following files part of it. Program directory structure: myprogram/ main.go server.go routines.go structs.go These different files contain different function. The structs.go file contains a list…
ElieLie
  • 369
  • 1
  • 3
  • 6
25
votes
4 answers

Refactoring Ruby on Rails i18n YAML files using dictionaries

This StackOverflow question gave me food for thought on what is a good structure for Rails i18n files, so I thought I'd share another structure for refactoring Rails i18n yml files for your consideration/criticism. Given that I would like to keep…
24
votes
5 answers

What are some efficient ways to combine two structures in MATLAB?

I want to combine two structures with differing fields names. For example, starting with: A.field1 = 1; A.field2 = 'a'; B.field3 = 2; B.field4 = 'b'; I would like to have: C.field1 = 1; C.field2 = 'a'; C.field3 = 2; C.field4 = 'b'; Is there a…
KennyMorton
  • 681
  • 1
  • 4
  • 9
24
votes
3 answers

Filter values from list in R

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…
chriga
  • 798
  • 2
  • 12
  • 29
23
votes
6 answers

Printing values of all fields in a C++ structure

Consider a simple structure: struct abc { int a; char b; } I got some value in a variable defined as its structure, and now I want to print the below. *a = [some value] b = [some character]* What is the best way to achieve this…
Zhinkaas
  • 295
  • 1
  • 3
  • 6
23
votes
1 answer

How do I dump the struct into the byte array without reflection?

I already found encoding/binary package to deal with it, but it depended on reflect package so it didn't work with uncapitalized(that is, unexported) struct fields. However I spent a week to find that problem out, I still have a question: if struct…
kroisse
  • 515
  • 1
  • 4
  • 9
22
votes
7 answers

Casting a byte array to a managed structure

Update: Answers to this question helped me code the open sourced project AlicanC's Modern Warfare 2 Tool on GitHub. You can see how I am reading these packets in MW2Packets.cs and the extensions I've coded to read big endian data in Extensions.cs. I…
AlicanC
  • 863
  • 1
  • 8
  • 12
22
votes
4 answers

What does this pointer of type structure definition mean (in C)?

In K&R Chapter 6, a declaration is mentioned as follows: struct{ int len; char *str; } *p; I couldn't understand which structure is this pointer p pointing to and if such a pointer definition is even valid because in all other examples…
Eulerian
  • 382
  • 2
  • 8