Implementing Sorting Algorithms with C++ Templates
This article demonstrates how to implement common sorting algorithms using C++ class templates with dynamic array storage. The implementation includes ranking sort, selection sort with early termination, bubble sort with early termination, and insertion sort.
Requirements
No STL containers (arrrays, vectors, etc.) Must use class templates (temp ...
Posted on Sat, 09 May 2026 10:41:46 +0000 by angelena
Demystifying C++ Templates: Function and Class Generic Programming
C++ templates enable writing generic code that works with different data types without rewriting the entire code for each type. They are broadly categorized into function templates and class templates.
Function Templates
Function templates provide a mechanism to define a generic function that can operate on different data types. The compiler ge ...
Posted on Sat, 09 May 2026 09:53:27 +0000 by h123z
Reusable C++ Templates for Fast I/O, Modular Arithmetic, and String Data Structures
Competitive programming demands a high degree of code reusability. Below is a curated set of templates that have been fine-tuned for typical on line judges, including a comprehensive header, fast input/output routines, a modular arithmetic wrapper, and implementations of the suffix automaton and suffix array.
Compact Header with Utilities
names ...
Posted on Fri, 08 May 2026 16:06:53 +0000 by infestedarch0n
C++ Class Templates: Mechanics and Functional Integration
Core Syntax Structure
The definition requires declaring type parameters before the class name. A typical implementation follows this pattern:
template<typename KeyType, typename ValueType>
class Entity
{
public:
Entity(KeyType id, ValueType data)
{
this->identifier = id;
this->metric = data;
}
void di ...
Posted on Thu, 07 May 2026 04:02:45 +0000 by cowfish