Added CopyTo functions, for copying to (and allocating) regular arrays.
Added CopyTo functions, for copying to (and allocating) regular arrays.

--- a/include/boilerplate.hpp
+++ b/include/boilerplate.hpp
@@ -414,6 +414,38 @@
 		bucketCount = 0;
 		itemCount = 0;
 	}
+	
+	// Using a const pointer here to highlight that the pointer MUST already be valid
+	// for use with this overload.
+	void CopyTo(T* const ptr) {
+		u64 items_copied = 0;
+		for (u32 bkIdx = 0; bkIdx < bucketCount; bkIdx++) {
+			u64 items_to_copy = std::min((u64)ITEMS_PER_BUCKET, itemCount - items_copied);
+			memmove(&(ptr[items_copied]), GetBucket(bkIdx), sizeof(T) * items_to_copy);
+			items_copied += items_to_copy;
+		}
+	}
+	
+	// If you really want us to set your pointer for you, we'll do it,
+	// but to help make sure you know what you're trying to do we're going to make you
+	// pass a pointer to the pointer
+	void CopyTo(T** const ptr, bool needs_allocating) {
+		T* array;
+		if (needs_allocating) {
+			array = new T[itemCount];
+			*ptr = array;
+		}
+		else
+		{
+			array = *ptr;
+		}
+
+		CopyTo(array);
+	}
+
+	void CopyTo(T** const ptr) {
+		CopyTo(ptr, true);
+	}
 
 	List(u32 max_buckets, u32 items_per_bucket) :
 		ITEMS_PER_BUCKET(items_per_bucket),