Skip to main content

Java BitSet Explained (with Practical Examples)

When developing applications, there are situations where we need to represent and manipulate large collections of binary values – typically true or false. Storing these values in a conventional data structure like a boolean[] or a HashSet<Integer> can be inefficient in terms of memory and speed. Java provides the BitSet class in the java.util package to address this problem. BitSet represents a sequence of bits that can grow dynamically and provides built-in methods for bit-level manipulation. In this article, we will cover: Introduction to BitSet Internal representation and advantages Common operations Basic usage example Real-world example: Attendance tracking Bitwise operations (AND, OR, XOR, ANDNOT) Performance comparison with boolean[] and HashSet Conclusion

Implementation of Distance Vector Routing (DVR) Algorithm in C++

Distance Vector Routing (DVR) is a decentralised routing protocol where each router maintains a table containing its estimated shortest distance to every other router in the network. Routers exchange these distance vectors with their neighbours, and each router updates its own table whenever a shorter path is discovered. The algorithm continues iterating until no table changes occur — a state known as convergence. DVR is the conceptual basis for real-world protocols such as RIP (Routing Information Protocol). This C++ program simulates DVR on a user-defined network. The user specifies the number of nodes and the distances between directly connected node pairs. The program iteratively updates routing tables until convergence and then prints each node's final routing table showing the shortest distance and the next-hop node to reach every destination.

8086 MASM Assembly Program for Addition of Two 8-bit Numbers

This blog post will guide you through a MASM (Microsoft Macro Assembler) program that performs the addition of two 8-bit numbers. While this is a fundamental operation, it demonstrates crucial assembly programming concepts such as data handling, register usage, and memory storage. Let’s dive in! Assembly Code

INT 3 vs INT 21h in 8086 Assembly: Breakpoint (CC) vs DOS Service Call

INT 3 is the one-byte CC debugger trap; INT 21h is the two-byte CD 21 gateway to DOS, where AH selects the service. Covers the opcode difference (NASM's int 3 is not CC), the stack frame, DEBUG behaviour, the standard AH function table from Ralf Brown's list, a runnable companion module and 14 viva questions.

🔗Angular directives: *ngIf, *ngSwitch, and *ngFor

Angular's structural directives are essential tools for dynamically shaping your templates. They control the very structure of the DOM by adding or removing elements based on conditions. Angular 17 provides three fundamental structural directives: *ngIf for conditional rendering, *ngSwitch for displaying elements based on multiple cases, and *ngFor for efficiently iterating and displaying lists of data. Understanding these directives is crucial for building dynamic and data-driven Angular applications. Let's explore each of these powerful tools and see how they can transform your templates!

🔗Data binding in Angular: Property binding, and event binding

Beyond interpolation, Angular offers more powerful data binding techniques: property binding and event binding. Property binding enables one-way flow of data from your component to the template, dynamically setting HTML element properties like src, value, disabled, and more. Conversely, event binding handles user interactions and events in the template, flowing data back to your component to trigger actions. Together, property and event binding form the backbone of interactive Angular applications, allowing seamless communication between your component logic and the user interface, creating truly dynamic experiences. Let's dive into each of them!

🔗Data binding in Angular: String Interpolation

Angular makes dynamic web pages a breeze with data binding, a powerful mechanism that connects your component's data to the HTML template. Interpolation is the simplest form of one-way data binding in Angular. Using the "moustache" syntax {{ }} in your HTML, you can effortlessly display component properties directly in the view. Angular will automatically update the template whenever the component data changes, creating dynamic and interactive user interfaces. Interpolation is perfect for displaying text, numbers, and other simple values, bringing your component's data to life in the template. Let's explore how this works!

Understanding Angular components: Templates, styles, and classes

Angular components are indeed the fundamental building blocks of Angular applications. They are self-contained, reusable units that manage a specific part of the user interface and its associated logic. Let's break down the three key parts in more detail: TypeScript Class: This is the brain of your component. It's where you write the logic that controls the component's behavior. It defines the data the component uses (properties). It handles user interactions and events (methods). Decorators like @Component attach metadata, linking the class to the template and styles. It's written in TypeScript, allowing for strong typing and better code organization.

Creating your first Angular application: Hello World

Alright, let's dive into the exciting world of Angular! Today, we're going to build your very first Angular application, the classic "Hello World," and explore the project structure that makes it all tick. Get ready to code, learn, and have some fun! Prerequisites: Before we begin, make sure you have the following installed: Node.js and npm: Angular relies on Node.js and its package manager, npm. You can download them from the official Node.js website. Angular CLI (Command Line Interface): The Angular CLI is a command-line tool that makes it easy to create, develop, and maintain Angular applications. Install it globally using npm: npm install -g @angular/cli Step 1: Creating a New Angular Project Open your terminal or command prompt. Navigate to the directory where you want to create your project and run the following command to create a new Angular project: ng new hello-world