HPCC-12290 Reimplement jarray using templates

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Meaning the assert in element would fail, I assume.

Feels like it would be cleaner to call element, then decrement used... Wouldn;t need to assertex(used) here then either.

PARAM result = element(SELF::used);
--SELF::used;
return result;