I
I
Ivan Ignatiev2014-12-04 21:30:05
Programming
Ivan Ignatiev, 2014-12-04 21:30:05

What is the name of such a data structure?

I apologize in advance if this is "what is the name of the blue thing above the head", the education did not come out.
I am writing something more from the field of esoteric than practically useful. Everything is strongly tied to this thing:
There is something (in a single copy) that has from zero to two cells ( [], [0], [0,1]). Any one can be read. Write only (almost) to the end, while the positions of the cells are shifted and the zero is forced out. You can "flip", completely clear (then it will be []). You cannot delete a specific cell, only all. Here is the pseudocode (all this does not apply to a specific PL, it is implemented very differently):

class WHAT_IT_IS singletone {
   private values = int[];
   public add(auto value) {
      if(this.values.length < 2)
         this.values[this.values.length] = value; 
      else 
         this.values[0] = this.values[1] = value;
     
  }
   public get(bool index) {
      return this.value[index];
   }
   public rever() {
      this.values[0] = this.values[this.values.length-1] = this.values[0];
   }
   public clear() {
      this.values = [];
   }
}

Is there a name for this? The closest thing seems to be a stack, but I'm not sure. It is very necessary to correctly call all things by their proper names, otherwise it is already harsh there.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
tugo, 2014-12-04
@0x9d8e

fixed size FIFO queue
shift register

F
FoxInSox, 2014-12-04
@FoxInSox

HZStack

C
Cyapa, 2014-12-04
@Cyapa

Specifically, there is no such pattern in programming. This is very close to a static rewrite queue, but
differs by the ability to read any element. You can google something like this: static FIFO queue.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question