当前位置: 首页>>代码示例>>Java>>正文


Java LinkedList.forEach方法代码示例

本文整理汇总了Java中java.util.LinkedList.forEach方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedList.forEach方法的具体用法?Java LinkedList.forEach怎么用?Java LinkedList.forEach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.LinkedList的用法示例。


在下文中一共展示了LinkedList.forEach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.util.LinkedList; //导入方法依赖的package包/类
public static void main(String[] args) {

        Joker joker = new Joker();
        SuperHero batman = new SuperHero();
        Citizen kane = new Citizen();


        LinkedList dreamTeam = new LinkedList();
        dreamTeam.add(new Object());
        dreamTeam.add(joker);
        dreamTeam.add(batman);
        dreamTeam.add(kane);

        dreamTeam.forEach((Object o)->{
            if(o instanceof Joker){
                ((Joker)o).speak();
            }
            else if(o instanceof SuperHero){
                ((SuperHero)o).speak();
            }
            else if(o instanceof Citizen){
                ((SuperHero)o).speak();
            }
        });
    }
 
开发者ID:zaleslaw,项目名称:Spring-Tutorial,代码行数:26,代码来源:DreamTeam_v_1_Problem.java

示例2: main

import java.util.LinkedList; //导入方法依赖的package包/类
public static void main(String[] args) {

        Joker joker = new Joker();
        SuperHero batman = new SuperHero();
        Citizen kane = new Citizen();


        LinkedList dreamTeam = new LinkedList();
        dreamTeam.add(new Object());
        dreamTeam.add(joker);
        dreamTeam.add(batman);
        dreamTeam.add(kane);

        dreamTeam.forEach((Object o)->{
            if(o instanceof Joker){
                ((Joker)o).speak();
            }
            else if(o instanceof SuperHero){
                ((SuperHero)o).speak();
            }
            else if(o instanceof Citizen){
                ((Citizen)o).speak(); //<--- Change type here
            }
        });
    }
 
开发者ID:zaleslaw,项目名称:Spring-Tutorial,代码行数:26,代码来源:DreamTeam_v_1_Solution.java

示例3: deleteCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void deleteCollection() {
    LinkedList<Picture> pictures = this.pictures;

    for (int i = 0; i < pictures.size(); i++)
        service.save(pictures.get(i), URL);
    service.delete(pictures);

    pictures.forEach(
            x -> {
                assertNull(service.findOne(x.getId()));
                Path p = Paths.get(x.getPath() + x.getName() + x.getFileType());
                boolean exists = Files.exists(p);
                if (exists)
                    fail("File exists!");
            }
    );
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:19,代码来源:PicturesServiceTest.java

示例4: deleteCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void deleteCollection() {
    LinkedList<CouponCode> couponCodes = this.couponCodes;

    service.save(couponCodes);
    service.delete(couponCodes);

    couponCodes.forEach(
            x -> assertNull(service.findOne(x.getId()))
    );
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:12,代码来源:CouponCodesServiceTest.java

示例5: saveCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void saveCollection() {
    LinkedList<Cookies> cookies = this.cookies;

    service.save(cookies);

    cookies.forEach(
            x -> assertTrue(x.equals(service.findOne(x.getId())))
    );
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:11,代码来源:CookiesServiceTest.java

示例6: deleteCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void deleteCollection() {
    LinkedList<Cookies> cookies = this.cookies;

    service.save(cookies);
    service.delete(cookies);

    cookies.forEach(
            x -> assertNull(service.findOne(x.getId()))
    );
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:12,代码来源:CookiesServiceTest.java

示例7: saveCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void saveCollection() {
    LinkedList<Order> orders = this.orders;

    service.save(orders);

    orders.forEach(
            x ->
                    assertTrue(x.equals(service.findOne(x.getId())))
    );
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:12,代码来源:OrdersServiceTest.java

示例8: deleteCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void deleteCollection() {
    LinkedList<Book> books = this.books;

    service.save(books);
    service.delete(books);

    books.forEach(
            x -> assertNull(service.findOne(x.getId()))
    );
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:12,代码来源:BooksServiceTest.java

示例9: saveCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void saveCollection() {
    LinkedList<UserRole> addresses = this.userRoles;

    service.save(addresses);

    addresses.forEach(x -> assertNotNull(service.findOne(x.getId())));
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:9,代码来源:UserRolesServiceTest.java

示例10: run

import java.util.LinkedList; //导入方法依赖的package包/类
public void run() {
	URClient c = new SecondaryURClient("172.31.1.141");
	c.setUpdateFrequence(RobotPackageType.JOINT_DATA, 1);
	c.addListener(this);
	try {
		c.connect();
	} catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	Motion m = c.getProxy(Motion.class);
	MotionExtended mx = c.getProxy(MotionExtended.class);
	Internals i = c.getProxy(Internals.class); 
	//JointPosition p = new JointPosition(new double[] {1.0,2.3,1.0,1.0,1.2,1.0});
	//CartesianPosition cart = new CartesianPosition(new double[] {1.0,2.3,1.0,1.0,1.2,1.0});
	LinkedList<JointPosition> list = new LinkedList<JointPosition>();
	JointPosition pos = new JointPosition(new double[] {3.1468286413,-0.8990190977,1.9971802631,-2.7342328062,-1.5739379194,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {2.9497809688,0.0958185759,1.234296847,-2.9124309228,-1.5739379194,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {3.2344441698,-0.5845107665,1.6077973069,-2.5652849346,-1.5760323146,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {3.4971162222,0.1420698011,0.9756390519,-2.7003734187,-1.5751596499,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {3.1468286413,-0.8990190977,1.9971802631,-2.7342328062,-1.5739379194,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {2.9497809688,0.0958185759,1.234296847,-2.9124309228,-1.5739379194,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {2.6808257311,-0.5845107665,1.6077973069,-2.5652849346,-1.5760323146,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {2.4581217185,0.1862266312,0.8848819308,-2.5797711674,-1.5781267097,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {3.1468286413,-0.8990190977,1.9971802631,-2.7342328062,-1.5739379194,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {2.9497809688,0.0958185759,1.234296847,-2.9124309228,-1.5739379194,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {2.9513517651,-0.5270894341,2.0724039538,-4.4717080765,-1.4184290831,3.1386255939});
	list.add(pos);
	pos = new JointPosition(new double[] {3.1468286413,-0.8990190977,1.9971802631,-2.7342328062,-1.5739379194,3.1386255939});
	list.add(pos);
	
	//m.movej(cart);
	//m.servoj(p, 1, 1, 4, 0.03f, 100);
	//mx.servoj(cart);
	
	mx.servoj(pos);
	list.forEach(p -> {
		mx.servoj(p);
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	});
	
	c.dispose();
}
 
开发者ID:tudrobotics,项目名称:urdriver,代码行数:59,代码来源:Example.java

示例11: deleteCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void deleteCollection() {
    LinkedList<UserRole> addresses = this.userRoles;

    service.save(addresses);
    service.delete(addresses);

    addresses.forEach(
            x -> assertNull(service.findOne(x.getId()))
    );
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:12,代码来源:UserRolesServiceTest.java

示例12: updatePathBandwidth

import java.util.LinkedList; //导入方法依赖的package包/类
private void updatePathBandwidth(PathInfoData path, int bandwidth, LinkedList<IslInfoData> islInfoDataLinkedList) {
    System.out.println("Update Path Bandwidth " + bandwidth + ": " + path);
    islInfoDataLinkedList.forEach(isl -> isl.setAvailableBandwidth(isl.getAvailableBandwidth() - bandwidth));
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:5,代码来源:PathComputerMock.java

示例13: deleteCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void deleteCollection() {
    LinkedList<User> users = this.users;

    service.save(users);
    service.delete(users);

    users.forEach(this::checker);
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:10,代码来源:UsersServiceTest.java

示例14: delete

import java.util.LinkedList; //导入方法依赖的package包/类
@Transactional
@Override
public void delete(SelfReference<T> entity) {

    Assert.notNull(entity, "The entity must not be null!");

    LinkedList<SelfReference<T>> treeEntities = bfsTraverse(entity);
    treeEntities.forEach(e -> this.entityManager.remove(e));
}
 
开发者ID:chaokunyang,项目名称:amanda,代码行数:10,代码来源:AbstractSelfReferenceRepository.java

示例15: saveCollection

import java.util.LinkedList; //导入方法依赖的package包/类
@Test
public void saveCollection() {
    LinkedList<Address> addresses = this.addresses;

    service.save(addresses);

    addresses.forEach(
            x ->
                    assertTrue(x.equals(service.findOne(x.getId())))
    );
}
 
开发者ID:xSzymo,项目名称:Spring-web-shop-project,代码行数:12,代码来源:AddressServiceTest.java


注:本文中的java.util.LinkedList.forEach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。