Where are Linked Lists used?

It’s the Day-1 of staying curious. I’ll talk more about it towards the end, but first - let’s get to the topic. Starting from my college life, I’ve always been excited to know the “how”, “why”, “what”, “where” questions of each data structure we would study. This series is not just about data structures though, anything that you can imagine with Computer Science - I hope to cover some of those in some more blog posts. ...

October 27, 2024 · 7 min · Kushashwa Ravi Shrimali

Porting a Tiling Window Manager Extenstion to C++ (Bismuth): Part-2 (getting closest relative window)

Hi everyone! In this blog, I will be discussing the algorithm used in Bismuth to find the closest relative window to be focused for focusWindowByDirection event. If you haven’t read the previous blog, make sure to give it a read here. Recap from the previous blog Let’s start with a quick recap though, in the previous blog, we discussed: focusWindowByDirection requires the following information: direction (from the user) - can be one of: right, left, top/up, bottom/down. activeWindow (from the current session) - this is needed since focusWindowByDirection event is a relative event to your current focused window. Neighbor window candidates (neighborCandidates) to your current window (activeWindow) and the given direction (direction). // declaration std::vector<Window> Engine::getNeighborCandidates(const FocusDirection &direction, const Window &basisWindow); // use std::vector<Window> neighborCandidates = getNeighborCandidates(direction, basisWindow); From these neighbor candidates (neighborCandidates), we will now find the closest relative window corner. To me, it was tricky to understand at first, so we’ll be discussing this in detail over in the later sections. Once we know the closest relative window corner, we’ll try to find the window which satisfies the corner condition. If there were multiple found, we’ll return the first one based on the time-stamp (last used) Understanding the scenario I want to start off with a visual, took me some time to draw it, but in case it doesn’t look good, I’m sorry! My drawing teacher in the high school tried his best, but… ...

July 31, 2022 · 6 min · Kushashwa Ravi Shrimali

Porting a Tiling Window Manager Extenstion to C++ (Bismuth): Part-1

Hi everyone! I understand it’s been a long time, and I’m so excited to be writing this blog today. In today’s blog, I wanted to talk about my journey (so far) on contributing to Bismuth (a KDE’s Tiling Window Manager Extension), mainly how and why I started, and where I am right now. The Story: Why KDE Plasma and Why Bismuth? For the last few months (close to a year), I’ve been using Pop OS (a linux distribution by System 76) which had this amazing automatic tiling window extension called pop-shell, and it was close to what I always needed: ...

July 23, 2022 · 8 min · Kushashwa Ravi Shrimali

Prefer const_iterators to iterators (Notes)

NOTE My notes on Chapter 3, Item 13 of Effective Modern C++ written by Scott Meyers. Some (or even all) of the text can be similar to what you see in the book, as these are notes: I’ve tried not to be unnecessarily creative with my words. :) In C++, iterators come handy to point at memory addresses of STL containers. For example, // C++11 std::vector<int> x {11, 9, 23, 6}; // begin() member function returns an iterator, which points to the first // memory address of the container x std::vector<int>::iterator it = x.begin(); While the general practice is to use const whenever possible, but programmers tend to use whenever it’s practical. const_iterators is particularly suggested when you want to use iterators, but you don’t need to modify what it points to. ...

September 26, 2021 · 5 min · Kushashwa Ravi Shrimali

Declaring Overriding Functions override (Notes)

NOTE My notes on Chapter 3, Item 12 of Effective Modern C++ written by Scott Meyers. Some (or even all) of the text can be similar to what you see in the book, as these are notes: I’ve tried not to be unnecessarily creative with my words. :) Overriding != Overloading Example of virtual function overriding: // Base class class Base { public: virtual void doWork(); // ... }; // Derived class from Base class Derived: public Base { public: // virtual is optional // this will "override" Base::doWork virtual void doWork(); // ... }; // This creates a "Base" class pointer to "Derived" class object std::unique_ptr<Base> upb = std::make_unique<Derived>(); // Derived doWork() function is invoked upb->doWork(); This is how virtual function overriding allows to invoke a “derived class function” from a base class interface. ...

September 25, 2021 · 4 min · Kushashwa Ravi Shrimali

Prefer Deleted Functions to Private Undefined Ones (Notes)

Prefer deleted functions to private undefined ones This item (11) in the chapter 3 focuses on: Why and How to prevent users calling particular functions? C++-98 and C++-11 approach What’s the difference between deleting a function vs declaring a member function private (and not defining them)? NOTE These are my notes on Chapter 3, Item 11 of Effective Modern C++ written by Scott Meyers. Some (or even all) of the text can be similar to what you see in the book, as these are notes: I’ve tried not to be unnecessarily creative with my words. :) ...

August 25, 2021 · 5 min · Kushashwa Ravi Shrimali

Prefer Scoped Enums over Unscoped Enums (Notes)

Scoped vs Unscoped Enums General rule: declaring a name inside curly braces is limited to that scope. Exception: C++-98 style Enums NOTE My notes on Chapter 3, Item 10 of Effective Modern C++ written by Scott Meyers. Some (or even all) of the text can be similar to what you see in the book, as these are notes: I’ve tried not to be unnecessarily creative with my words. :) ...

August 14, 2021 · 5 min · Kushashwa Ravi Shrimali

Union Find Problem, and a naive implementation (C++)

Hi Everyone, today I want to talk about Union Find Problem. This is going to be a series covering: Union Find Problem (this blog) Solutions to Union Find (1): Quick Find Solutions to Union Find (2): Quick Union Solutions to Union Find (3): Weighted Quick Union Applications of Union Find (perculation and more) Cool project using Union Find Solving some competitive programming questions using Union Find Each blog will try to cover very basic concepts behind the topic, and also what it’s all about. ...

August 14, 2021 · 7 min · Kushashwa Ravi Shrimali

Prefer Alias Declarations to Typedefs (Notes)

One solution to avoiding using long type names: // So C++98 like typedef std::unique_ptr<std::unordered_map<std::string, std::string>> UPtrMapSS; ...

August 12, 2021 · 3 min · Kushashwa Ravi Shrimali

Function Pointers and Function Objects in C++

In today’s blog, we’ll talk about two important concepts in C++: Function Pointers and Function Objects. Please note that, function objects are commonly referred as functors but we have failed to notice any official alias to the name. Hence, we’ll restrict ourselves to using Function Objects in this blog. ...

July 18, 2021 · 9 min · Kushashwa Ravi Shrimali