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-cohama.adb | |
parent | 1ba878a991190f847e28782e62f9d2f96785f3cd (diff) | |
download | gcc-a31945d7ce7a91aeb5afd885777f0e87a6404188.tar.gz |
[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-cohama.adb')
-rw-r--r-- | gcc/ada/a-cohama.adb | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/gcc/ada/a-cohama.adb b/gcc/ada/a-cohama.adb index c06ba9e35e4..20e10e8daf9 100644 --- a/gcc/ada/a-cohama.adb +++ b/gcc/ada/a-cohama.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2004-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2011, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -35,6 +35,8 @@ pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Operations); with Ada.Containers.Hash_Tables.Generic_Keys; pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Keys); +with System; use type System.Address; + package body Ada.Containers.Hashed_Maps is type Iterator is new @@ -131,6 +133,41 @@ package body Ada.Containers.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, New_Item => Node.Element); + 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 -- -------------- @@ -158,6 +195,34 @@ package body Ada.Containers.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 -- --------------- |