Warning, /firebird/firebird-ng/src/app/utils/list.utils.ts is written in an unsupported language. File is not indexed.
0001 /**
0002 * @summary Filters out items from list1 that are present in list2 and returns a new list.
0003 * @param {T[]} list1 - The first list of items.
0004 * @param {T[]} list2 - The second list of items to be removed from the first list.
0005 * @return {T[]} A new list with items from list1 that are not in list2.
0006 */
0007 export function filterIntersectingItems<T>(list1: T[], list2: T[]): T[] {
0008 const set2 = new Set(list2);
0009 return list1.filter(item => !set2.has(item));
0010 }
0011
0012 /**
0013 * @summary Removes items from list1 that are present in list2 in place.
0014 * @param {T[]} list1 - The first list of items.
0015 * @param {T[]} list2 - The second list of items to be removed from the first list.
0016 */
0017 export function removeIntersectingItemsInPlace<T>(list1: T[], list2: T[]): void {
0018 const set2 = new Set(list2);
0019 let i = 0;
0020 while (i < list1.length) {
0021 if (set2.has(list1[i])) {
0022 list1.splice(i, 1); // Remove the item at index i
0023 } else {
0024 i++;
0025 }
0026 }
0027 }