KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Note: Hash-Based Set Class Component
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: October 30, 2023


In computer programming, a set is an abstract data structure that stores a list of unique values. Depending on the type of implementation, the set of values can either be ordered or unordered. A set data structure normally has some utility functions that can add non-duplicate values, remove existing values, and check if a value already exists in the set. Sets are commonly utilized in various computer application fields such as data analysis and algorithms. They are mainly used to perform operations on sets of values efficiently and systematically.

This technical note will discuss how to implement a basic Set class in v20. It will be hash-based, meaning the class will use hash tables to store its set of values in no particular order. Only text and number values will be accepted, but the class will be extensible for additional value types. The Set class will have five main functions—“add”, “has”, “delete”, “clear”, and “collection”—and an additional “size” property.

Download Complete Tech Note: Tech Note Document

Commented by Tammo Fornalik on April 22, 2024 at 12:09 PM
Nice. It would also be nice if such standard implementations, which have been around for 30 or more years in other languages, were not implemented by us, but by you. It's fantastic that you have implemented Collections in 4D and the Collection class is one of the best architectural extensions in 4D besides OOP! I just sometimes don't know why we have to build canonical low-level functionality ourselves. Do we pay for this great freedom that isn't freedom? Do we pay for this freedom in other languages? What is the definition of a RAD tool like 4D in 2024? Java 8: https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html Rust: https://doc.rust-lang.org/std/collections/struct.HashSet.html TypeScript: https://www.javatpoint.com/typescript-set JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set