diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-11-04 10:58:07 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-11-04 10:58:07 +0100 |
commit | a31945d7ce7a91aeb5afd885777f0e87a6404188 (patch) | |
tree | 5c092a2498a4cada2cfb133adc362e3c6001ea2e /gcc/ada/a-cihama.adb | |
parent | 1ba878a991190f847e28782e62f9d2f96785f3cd (diff) | |
download | gcc-a31945d7ce7a91aeb5afd885777f0e87a6404188.zip gcc-a31945d7ce7a91aeb5afd885777f0e87a6404188.tar.gz gcc-a31945d7ce7a91aeb5afd885777f0e87a6404188.tar.bz2 |
[multiple changes]
2011-11-04 Matthew Heaney <heaney@adacore.com>
* a-cdlili.ad[sb], a-cidlli.ad[sb], a-coorse.ad[sb], a-ciorse.ad[sb],
a-coorma.ad[sb], a-ciorma.ad[sb], a-coormu.ad[sb], a-ciormu.ad[sb],
a-cohama.ad[sb], a-cihama.ad[sb], a-cohase.ad[sb], a-cihase.ad[sb],
a-convec.ad[sb], a-coinve.ad[sb] (Assign, Copy): New operations
added to package.
2011-11-04 Robert Dewar <dewar@adacore.com>
* sem_ch12.adb: Minor reformatting
2011-11-04 Gary Dismukes <dismukes@adacore.com>
* bindgen.adb (Gen_Elab_Calls): In the case of the AAMP target,
initialize elaboration entities to zero when specs are processed.
From-SVN: r180930
Diffstat (limited to 'gcc/ada/a-cihama.adb')
-rw-r--r-- | gcc/ada/a-cihama.adb | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/gcc/ada/a-cihama.adb b/gcc/ada/a-cihama.adb index d4f2c1d9..b90c542 100644 --- a/gcc/ada/a-cihama.adb +++ b/gcc/ada/a-cihama.adb @@ -35,6 +35,8 @@ pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Keys); with Ada.Unchecked_Deallocation; +with System; use type System.Address; + package body Ada.Containers.Indefinite_Hashed_Maps is procedure Free_Key is @@ -132,6 +134,41 @@ package body Ada.Containers.Indefinite_Hashed_Maps is HT_Ops.Adjust (Container.HT); end Adjust; + ------------ + -- Assign -- + ------------ + + procedure Assign (Target : in out Map; Source : Map) is + procedure Insert_Item (Node : Node_Access); + pragma Inline (Insert_Item); + + procedure Insert_Items is new HT_Ops.Generic_Iteration (Insert_Item); + + ----------------- + -- Insert_Item -- + ----------------- + + procedure Insert_Item (Node : Node_Access) is + begin + Target.Insert (Key => Node.Key.all, New_Item => Node.Element.all); + end Insert_Item; + + -- Start of processing for Assign + + begin + if Target'Address = Source'Address then + return; + end if; + + Target.Clear; + + if Target.Capacity < Source.Length then + Target.Reserve_Capacity (Source.Length); + end if; + + Insert_Items (Target.HT); + end Assign; + -------------- -- Capacity -- -------------- @@ -159,6 +196,34 @@ package body Ada.Containers.Indefinite_Hashed_Maps is return Find (Container, Key) /= No_Element; end Contains; + ---------- + -- Copy -- + ---------- + + function Copy + (Source : Map; + Capacity : Count_Type := 0) return Map + is + C : Count_Type; + + begin + if Capacity = 0 then + C := Source.Length; + + elsif Capacity >= Source.Length then + C := Capacity; + + else + raise Capacity_Error + with "Requested capacity is less than Source length"; + end if; + + return Target : Map do + Target.Reserve_Capacity (C); + Target.Assign (Source); + end return; + end Copy; + --------------- -- Copy_Node -- --------------- |