Questions tagged [lifo]

LIFO is an acronym that stands for last in, first out. In computer science and queueing theory this refers to the way items stored in some types of data structures are processed.

LIFO is an acronym that stands for last in, first out. In computer science and queueing theory this refers to the way items stored in some types of data structures are processed.

63 questions
13
votes
1 answer

is FILO always LIFO?

A stack is referred to as a Last-In-First-Out (LIFO) and First-In-Last-Out (FILO) structure. Is there any data structure that is LIFO but not FILO (or other direction) ? A counter example that proves "FILO doesn't always mean LIFO"
Raymond Chenon
  • 11,482
  • 15
  • 77
  • 110
12
votes
2 answers

How to implement LIFO for multiprocessing.Queue in python?

I understand the difference between a queue and stack. But if I spawn multiple processes and send messages between them put in multiprocessing.Queue how do I access the latest element put in the queue first?
shijuza
  • 191
  • 3
  • 9
9
votes
3 answers

Python: First In First Out Print

I'm a beginner in python and I'm having an issue with this program: The program below is a Last In First Out (LIFO). I want to make it First in First Out (FIFO) Program. from NodeList import Node class QueueLL: def __init__(self): …
arcwinolivirus
  • 119
  • 1
  • 2
  • 6
6
votes
3 answers

Can't Control Order of String Set in Shared Preferences

This is my first stackoverflow question. I have done lot of googling on this. On Hashsets, Treesets, LinkedHashSets, Collections, Stacks (Stack class is deprecated?)... I realize I could just use SQLite but I'm trying to avoid that for the time…
Nerdy Bunz
  • 6,040
  • 10
  • 41
  • 100
5
votes
3 answers

A MailboxProcessor that operates with a LIFO logic

I am learning about F# agents (MailboxProcessor). I am dealing with a rather unconventional problem. I have one agent (dataSource) which is a source of streaming data. The data has to be processed by an array of agents (dataProcessor). We can…
NoIdeaHowToFixThis
  • 4,484
  • 2
  • 34
  • 69
4
votes
3 answers

how to prevent corruption in concurrent lifo stack implemented with atomic compare and swap

Below is a simplified C program that demonstrates a problem I am having with a concurrent stack implemented using the GNU built in compare and swap on an intel cpu. It took me a while to understand what was happening, but now that I do I see that…
drawnonward
  • 53,459
  • 16
  • 107
  • 112
3
votes
1 answer

How to properly implement stack in Direction Array Reduction challenge in Swift

I'm trying to solve a coding challenge in Swift. The task is to build a function that takes in an array of directions ex: ["NORTH", "WEST", "EAST", "NORTH", "EAST", "SOUTH"]. Any opposite directions that are next to each other in the array should be…
msiller455
  • 53
  • 7
3
votes
1 answer

stack.pop() inside of if statement

I am wondering if calling the pop() method from the Stack data structure within an if statement will pop off the first element from the stack? Here is an example of code: public void pop() { if(stack.pop() == min) min=stack.pop(); } Will this…
joshuar500
  • 164
  • 1
  • 15
3
votes
2 answers

Calculate results with LIFO method via TSQL

I want to make calculation via LIFO (last in first out) method with TSQL. Using LIFO method will require you to calculate profit/loss by selling last transactions. Example how it works: deal is concluded on 1 march we BUY 10 stocks for 5 dollars…
Kirill Pashkov
  • 3,118
  • 1
  • 15
  • 20
3
votes
1 answer

How do I create a Stack or LIFO for GNU Parallel in Bash

While my original problem was solved in a different manner (see comment thread under this question, as well as the edits to this question), I was able to create a stack/LIFO for GNU Parallel in Bash. So I will edited my background/question to…
Jake
  • 625
  • 6
  • 16
3
votes
1 answer

Implementation of LIFO list in Scheme

I'm having some trouble implementing a LIFO list in Scheme. My code works just fine if I only want to push one element on to the stack, but I want to be able to push several elements. Here is my code: (define (make-stack) (let ((stack '())) …
user16655
  • 1,901
  • 6
  • 36
  • 60
3
votes
2 answers

Is there a ready to use Java lifo class (stack) with push to front on reinsertion?

I'm looking for a Java LIFO structure with unique values. Furthermore it should promote an already inserted value to the front on reinsertion. It would be useful to track the order of focused windows for example. I know that it isn't really hard to…
raffael
  • 2,427
  • 4
  • 26
  • 42
3
votes
1 answer

Semaphore or lock with waiting list served in LIFO order

Looking for efficient semaphore or lock with LIFO ordered list of waiting threads to try to minimize cache and page misses in following implementation of FixedThreadPoolExecutor.
Andriy Plokhotnyuk
  • 7,883
  • 2
  • 44
  • 68
2
votes
0 answers

Reasons to use a LIFO cache eviction policy?

On the Wikipedia page about cache replacement policies, there is a small section about LIFO/FILO policy: Last in first out (LIFO) or First in last out (FILO) Using this algorithm the cache behaves in the same way as a stack and opposite way as a…
Ricola
  • 2,621
  • 12
  • 22
2
votes
1 answer

LIFO Queue that drops elements off the back end of it when length is exceeded?

I am not looking to preserve data. I am looking for a container that contains the last N items I stuffed in it, and allows items to fall off the back end of it and expire. blocking_lifo =…
Chris
  • 28,822
  • 27
  • 83
  • 158
1
2 3 4 5