Questions tagged [packing]

Use this tag for questions related to packing, which can extend from struct packing to grouping elements together.

In C, will prevent the compiler from adding padding to a struct, which will save some memory, but may affect access speed to the members of the struct (since it may not memory-aligned).

However, has a general meaning as well, when you want to group/cluster similar elements together.

347 questions
14
votes
4 answers

How to make class in C#, that can be cast to DateTime?

How can I make class, that can be cast to DateTime. But I need to cast my class, when it packed. For example: object date1 = new MyDateTime(); DateTime date2 = (DateTime)date1; I need directly this working example. I know how to do it, but my way…
Evgeny Ekim
  • 241
  • 3
  • 13
12
votes
1 answer

Packing and unpacking elements from list in R

I have two questions related to using list in R and I am trying to see how I can improve my naive solution. I have seen questions on similar topic here but the approach described there is not helping. Q1: MWE: a <- c(1:5) b <- "adf" c <-…
skaur
  • 167
  • 1
  • 1
  • 11
12
votes
3 answers

Rectangle packing with constraints

I want to pack a set of rectangles (example): So that the total height is as low as possible with the constraint that the rectangles must end up in the same column they started in. The rectangles are allowed to "move" through each other to reach…
Andreas Brinck
  • 51,293
  • 14
  • 84
  • 114
11
votes
1 answer

What is the most efficient way in Java to pack bits into byte[] and read it back?

I currently use these two functions to pack and read bits in a byte array. Wondering if anybody has any better ideas or faster ways to do it? Edited the program with a few more optimization and tabled a few calculations. Currently 100mil Put and…
user972178
  • 113
  • 1
  • 6
10
votes
2 answers

How to pack spheres in python?

I am trying to model random closed packing spheres of uniform size in a square using python. And the spheres should not overlap but I do not know how to do this I have so far: Code: import random, math, pylab def show_conf(L, sigma, title,…
altarbza
  • 426
  • 7
  • 13
10
votes
2 answers

Algorithm/approximation for combined independent set/hamming distance

Input: Graph G Output: several independent sets, so that the membership of a node to all independent sets is unique. A node therefore has no connections to any node in its own set. Here is an example path. Since clarification was called for here…
tarrasch
  • 2,630
  • 8
  • 37
  • 61
10
votes
4 answers

Fitting rectangles together in optimal fashion

I was wondering if anyone knows of any algorithms suited to fitting together N number of rectangles of unknown size into the smallest possible containing rectangle. By optimal I mean with reducing the amount of white space left over in the…
madcapnmckay
  • 15,782
  • 6
  • 61
  • 78
10
votes
3 answers

Fast block placement algorithm, advice needed?

I need to emulate the window placement strategy of the Fluxbox window manager. As a rough guide, visualize randomly sized windows filling up the screen one at a time, where the rough size of each results in an average of 80 windows on screen without…
James Morris
  • 4,867
  • 3
  • 32
  • 51
9
votes
8 answers

Text packing algorithm

I bet somebody has solved this before, but my searches have come up empty. I want to pack a list of words into a buffer, keeping track of the starting position and length of each word. The trick is that I'd like to pack the buffer efficiently by…
Adrian McCarthy
  • 45,555
  • 16
  • 123
  • 175
9
votes
3 answers

Pack four bytes in a float

I'm writing a shader (HLSL), and I need to pack a color value into the R32 format. I've found various pieces of code for packing a float into the R8G8B8A8 format, but none of them seem to work in reverse. I'm targeting SM3.0, so (afaik) bit…
YellPika
  • 2,872
  • 2
  • 28
  • 31
9
votes
3 answers

Algorithm to fit windows on desktop (like tile)

I searching algorithm to solve problem like this: I have few windows, each window can be moved and re sized but with specified ratio between width and height, eg. 2:1 (height:width). Each window can't be on other window and all windows must be fully…
Svisstack
  • 16,203
  • 6
  • 66
  • 100
9
votes
4 answers

Maximum packing of rectangles in a circle

I work at a nanotech lab where I do silicon wafer dicing. (The wafer saw cuts only parallel lines) We are, of course, trying to maximize the yield of the die we cut. All the of die will be equal size, either rectangular or square, and the die are…
Patrick
  • 91
  • 1
  • 2
9
votes
1 answer

C++ - using GTest value-parameterized tests with structs causes valgrind errors

Can you help me understand what is going on here with GTest and struct packing? The problem seems to be related to how a struct is packed when used as a value in a value-parameterised test in GTest. Taking the straightforward approach of…
davidA
  • 12,528
  • 9
  • 64
  • 96
9
votes
6 answers

Piece together several images into one big image

I'm trying to put several images together into one big image, and am looking for an algorithm which determines the placing most optimally. The images can't be rotated or resized, but the position in the resulting image is not important. edit: added…
Linor
  • 1,850
  • 2
  • 17
  • 17
9
votes
5 answers

What tools are there to cross-create an OSX installer for a python package?

Distutils offers existing solutions to build a Windows self-extracting EXE. Notably, I can create the package even if I'm on Ubuntu (which is essential given our automated build process). How do I build an osx installer from an Ubuntu machine? (This…
UsAaR33
  • 3,536
  • 2
  • 34
  • 55
1
2
3
23 24