Common Lisp Package: GROUP-BY

README:

FUNCTION

Public

GROUP-BY (LIST &KEY (KEY #'CAR) (VALUE #'CDR) (KEY-FN #'IDENTITY) (TEST #'EQUAL))

groups the list into an alist using the key function and value function to group by key, with a list of all values for that key. key is used to determine the key in the a-list value is used to determin the value in the a-list key-fn is passed as the :key to assoc test is passed as the :test to assoc eg: (group-by '((a 1 2) (a 3 4) (b 5 6))) => ((A (1 2) (3 4)) (B (5 6)))

GROUP-BY-REPEATED (LIST &KEY KEYS TESTS)

Returns an alist tree that represents the items in the list as categorized by keys (compared with tests) ex: ((a 3 sam) (c 4 bob) (a 3 ted)) keys: a list of key functions that describe the categorizations in order tests: how we are testing whether or not two keys are equal, defaults to #'equal

GROUPED-LIST-SPEED-TESTER (&KEY LIST KEYS TESTS HASH-TESTS (ITERATIONS 10) ACTIONS)

A function to help asses which implementation will work best in your given scenario actions : (lambda (gl) ...) -to help test whatever grouped list operations you will need to do repeatedly

MAKE-GROUPED-LIST (INP &KEY TESTS KEYS (GROUPING-IMPLEMENTATION ALIST))

Given a list of input, produce a grouped-list CLOS object that contains the original list, configuration about the groupings and the result tree of grouped-list objects ''keys'': a list of keys to group by<br /> ''tests'': a list of tests to compare the keys with<br /> ''grouping-implmentation'': What data structure should be used to perform the grouping<br /> '':alist, :tree , :hash-table''<br /> The implementation doesnt change the output, but it does change the performance characteristics of the grouped-object (see: grouped-list-speed-tester for help deciding which to use)

Private

Undocumented

FIND-SINGLE-SUB-CATEGORY (GL KEY-VALUE &KEY TEST)

GENERIC-FUNCTION

Public

CATEGORIZE-ITEM (ITEM ROOT &KEY KEYS TESTS &ALLOW-OTHER-KEYS)

Insert a new item into a grouped list

Undocumented

ADD-ITEM-TO-GROUPING (ITEM GL)

CHILD-GROUPINGS (GL)

ITEMS-IN-GROUP (GL &REST KEY-VALUES)

MAKE-CHILD-GROUPED-LIST (GL KEY-VALUE GROUPED-LIST)

Private

Undocumented

%GROUPING-ITEMS (GL)

SLOT-ACCESSOR

Public

KEY-VALUE (OBJECT)

If this is a subgrouping of another grouped-list, what is the key this grouped-list represents in the parent grouping (mostly for testing)

SETFKEY-VALUE (NEW-VALUE OBJECT)

If this is a subgrouping of another grouped-list, what is the key this grouped-list represents in the parent grouping (mostly for testing)

KEYS (OBJECT)

A list of key functions we will use to group the list

SETFKEYS (NEW-VALUE OBJECT)

A list of key functions we will use to group the list

PARENT-GROUPING (OBJECT)

If this is a subgrouping of another grouped-list, what is the parent grouping we are apart of (mostly for testing)

SETFPARENT-GROUPING (NEW-VALUE OBJECT)

If this is a subgrouping of another grouped-list, what is the parent grouping we are apart of (mostly for testing)

TESTS (OBJECT)

A list of test functions we will use to test key equality tree: defaults to #'equal hash-table: this be a single hash-equality symbol (defaults to 'equal)

SETFTESTS (NEW-VALUE OBJECT)

A list of test functions we will use to test key equality tree: defaults to #'equal hash-table: this be a single hash-equality symbol (defaults to 'equal)

Private

GROUPING-IMPLEMENTATION (OBJECT)

What data structure should be used to perform the grouping :list, :hash-table

SETFGROUPING-IMPLEMENTATION (NEW-VALUE OBJECT)

What data structure should be used to perform the grouping :list, :hash-table

Undocumented

%CHILD-GROUPINGS (OBJECT)

SETF%CHILD-GROUPINGS (NEW-VALUE OBJECT)

%ITEMS (OBJECT)

SETF%ITEMS (NEW-VALUE OBJECT)

ORIG-LIST (OBJECT)

SETFORIG-LIST (NEW-VALUE OBJECT)

CLASS

Public

GROUPED-LIST

This class represents a list that we have grouped by multiple key values ala one of the group-by-repeatedly functions