Tag Info

New answers tagged

1

The only place where I usually use lists is where I need to erase elements and not invalidate iterators. std::vector invalidates all iterators on insert and erase. std::list guarantees that iterators to not deleted element are still can be considered valid.


0

You should consider the size of the elements in the container. int elements vector is very fast as most of the data fits inside the CPU cache (and SIMD instructions can probably be used for data copying). If the element's size is greater then the result of test 1 and 3 could change significantly. From a very comprehensive performance comparison: This ...


1

In addition to the other answers already provided, lists have certain features that don't exist in vectors (because they would be insanely expensive.) The splice and merge operations being the most significant. If you frequently have a bunch of lists that need to be appended or merged together, a list is probably a good choice. But if you don't need to ...


3

No not really. The problem is that with every variation in the spreadsheet you end up with a different interpretation of the indicators. So given the same set of inputs each sheet will come up with different recomendations. Either determine what is the "correct" set of indicators and formulas to be used in the application. or - If you really want to ...


0

The classic way to store a tree in a database is to use a self-referential table. If you take James Anderson's branch table and add an optional parentBranchID field, you are there. The only branch with a null parentBranchId will be the root node. Similarly, read the whole table into memory using branch classes that have both a parentBranchID and a ...


2

Branches is fairly easy: Root of tree is "1". First bifurcation results in branches "1x1" and "1x2" counting from the left. So the top rightmost branch in your tree is labeled "1x2x2x2". This schema is quite useful for querying as you can get all the sub branches of say "1x2" by a simple " LIKE '1x2%' " in SQL. Squirrel position is more problematic but ...


2

Queues are generally considered to be an abstract data type that only has enqueue and dequeue operations. So in the general case, we can't use any other functions. Let's look at the case of a FIFO queue that only supports these two operations and additionally has a size property. Getting and removing the middle element is trivial by also removing all ...


-1

There seems to be too many business rules that rely on the existence of a referee id: Who is the ref and whethere or not this event is streamed. For all the streamed/non-refereed events, the field is null. It would be difficult to look at your database and make this determination. I don't know how much of your data structure you could change, but this ...


2

Let us assume there's an EVENT table and a REFEREE table, and that the first one has a PK (referee_id) which refers to REFEREE's PK (referee_id). Then one "TBC" referee (not a real person), is inserted in table REFEREE, so any event that has no referee assigned a the moment of insertion can at least be assigned the code of that imaginary referee. That ...


1

I tend to agree with Doc Brown's answer: you'll better use a database. That might be sqlite or a real database server: mongodb or postgresql, etc.... You could perhaps use an indexed file like GDBM (instead of a database) in some limited circumstances. If the data is small (which apparently it is not) you might consider persisting all of it in some textual ...


1

Short answer: consider to use a database. Databases allow you easily to save only the changed part of a whole bunch of data very quickly, whilst you don't have to care for the unchanged parts. And here is a former SO post dealing with the topic of storing tree structures in databases.


1

Different problems need different traversal strategies. Therefore my suggestion would be to implement a separate Traverser using the strategy pattern. The Visitor pattern can require alot of boilerplate code. Its actually well-suited to automated code-generation (see Java's jaxb-visitor). My suggestion is to implement a basic/default visitor that ...


1

To keep collisions at a minimum, there are two big things you definitely need to get right: The hashmap's size must be sufficient to fit most or all of the data without collisions. Of course, you can have a hashmap that dynamically resizes itself after seeing a lot of collisions; you should still get O(1) amortized as long as this doesn't happen too often. ...


1

I don't think there's any good way to fix your overflow problem with the constraints given. Renumbering your heap periodically means a stop-the-world housekeeping operation, which I reckon needs O(n log n) time without extra allocation, or perhaps O(n) time with O(n) temporary space. Note that if O(n log n) stop-the-world operations aren't acceptable - you ...


1

Map the stars onto an Isocahedron(https://en.wikipedia.org/wiki/Icosahedron) and if you need more fine binning, then just subdivide the triangles.


2

Your current solution has a major down side in that it is not thread safe. I would definitely redesign so that you can have multiple tree operations preformed in parallel. Assuming that nodes are purely internal to the tree structure, and always called via the tree, I would consider simply having their owner tree passed in as a parameter when you call any ...


1

There's good information to be found on this topic in the paper on the implementation of Venti (Plan 9's deduplicating filesystem) and its data structure approach. In addition, Marco Peereboom has some implementation resources on his work on Epitome (which was heavily inspired by Venti). You can see some slides or a paper from which the slides were based ...


1

My question is: Would you recommend using this in a serious project? Yes! Here is something that is mostly true about library functions: they necessarily have to be generally applicable in order to accommodate many users with different requirements. If you know the underlying algorithm, the library function is going to be larger and slower than your ...



Top 50 recent answers are included