2024-09-14 06:41:52 +00:00
|
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System;
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Rokojori
|
|
|
|
{
|
2025-01-03 12:09:23 +00:00
|
|
|
public class MapList<K,V>:Map<K,List<V>>
|
2024-09-14 06:41:52 +00:00
|
|
|
{
|
2025-01-03 12:09:23 +00:00
|
|
|
public void ForEach( Action<K,List<V>> callback )
|
|
|
|
{
|
|
|
|
foreach ( var vk in this )
|
|
|
|
{
|
|
|
|
callback( vk.Key, vk.Value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-14 06:41:52 +00:00
|
|
|
public void Add( K key, V value )
|
|
|
|
{
|
|
|
|
if ( ! ContainsKey( key ) )
|
|
|
|
{
|
|
|
|
this[ key ] = new List<V>();
|
|
|
|
}
|
|
|
|
|
|
|
|
this[ key ].Add( value );
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Remove( K key, V value )
|
|
|
|
{
|
|
|
|
if ( ! ContainsKey( key ) )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var list = this[ key ];
|
|
|
|
|
|
|
|
list.Remove( value );
|
|
|
|
|
|
|
|
if ( list.Count == 0 )
|
|
|
|
{
|
|
|
|
Remove( key );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|