Questions tagged [container-classes]

9 questions
5
votes
3 answers

Thread-Safe Buffered Observable Priority Queue?

I'm writing a program where one thread needs to push items onto the queue, and one or more threads pops items off the queue and processes them. To avoid running out of memory, I'd like the producer thread to sleep when the queue gets full. Some…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
3
votes
2 answers

When to prefer stack/queue over deque?

I know that stack/queue is container adaptor that use deque as its default underlying container. But why the hassle when we can just use deque as a stack or a queue? And I don't see the situations where we have to use stack/queue with different…
1
vote
1 answer

[Closed for the moment]Python class definition is not defined. Error

I am programming on my phone. I've created the class character to hold all the information about the character such as the Hp. After defining the hp, I make a function called getHp() which returns the hp. Later when I call "getHp()" in my "stats()"…
1
vote
1 answer

NSUnknownKeyException reason: '[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key name

I am devoleping an application for creating a search bar above contacts list.If i press the search bar app gets crashed .I debugged the application and found that the crash occuars at this line. filteredCandyArray = [NSMutableArray…
Suraj K Thomas
  • 5,773
  • 4
  • 52
  • 64
0
votes
1 answer

Android Faster Access : Container class or xml resource

I have a list of strings (messages and urls) which I want to place in a common file. Would it be more efficient to place them in a container class or as an xml resource? If I want to use the strings in my xml layouts, I guess I have to put my string…
0
votes
2 answers

What is the importance of `&` when overloading the `[]` operator for a container class?

Let's say I have this simple container class class Array{ private: int m_l{}; int *m_d{}; public: Array() = default; Array(int len) : m_l{len} { assert(len >= 0); if (len > 0) { m_d…
user14248283
0
votes
4 answers

Returning deep copies of objects when overloading the = operator

So I making a container class for integers and I want to overload the = operator so that I can return a deep copy of the object. My code works but the two objects point to the same address. This is the main.cpp file: int main (int argc, const char *…
0
votes
2 answers

Inserting Nodes in to a Linked List in Sorted Order

I need help inserting data from class node into a linked list. List is a container for nodes. They need to be sorted based on last name, then first name, and age. (I already have operator functions to compare them) I'm just not sure how to use the…
0
votes
2 answers

c++ call private function in container class

If I have two classes: class worker { Top *mp_parent; worker(Top *parent) : mp_parent(parent) {}; int doSomeWork() { int i = mp_parent->privateFunction(); // This is the function I want to call } } class Top { private: …
code_fodder
  • 15,263
  • 17
  • 90
  • 167