org.organicdesign.fp.collections.MutableMap Maven / Gradle / Ivy
// Copyright 2016 PlanBase Inc. & Glen Peterson
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.organicdesign.fp.collections;
import java.util.Map;
/**
Interface for mutable (hash) map builder.
*/
public interface MutableMap extends BaseUnsortedMap {
/** {@inheritDoc} */
@Override
MutableMap assoc(K key, V val);
/** {@inheritDoc} */
@Override default MutableMap assoc(Map.Entry entry) {
return assoc(entry.getKey(), entry.getValue());
}
@Override default MutableSet> entrySet() {
return map(e -> (Map.Entry) e).toMutableSet();
}
/** Returns a mutable view of the keys contained in this map. */
@Override default MutableSet keySet() {
return map(e -> ((Map.Entry) e).getKey()).toMutableSet();
}
/** Returns an immutable version of this mutable map. */
ImMap immutable();
/** {@inheritDoc} */
@Override
MutableMap without(K key);
}